mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 22:52:06 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2016 Therp BV <http://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from psycopg2.extensions import ISQLQuote
|
||||
|
||||
|
||||
class IdentifierAdapter(ISQLQuote):
|
||||
def __init__(self, identifier, quote=True):
|
||||
self.quote = quote
|
||||
self.identifier = identifier
|
||||
|
||||
def __conform__(self, protocol):
|
||||
if protocol == ISQLQuote:
|
||||
return self
|
||||
|
||||
def getquoted(self):
|
||||
def is_identifier_char(c):
|
||||
return c.isalnum() or c in (["_", "$", " "] if self.quote else ["_", "$"])
|
||||
|
||||
format_string = '"%s"'
|
||||
if not self.quote:
|
||||
format_string = "%s"
|
||||
return format_string % "".join(filter(is_identifier_char, self.identifier))
|
||||
Loading…
Add table
Add a link
Reference in a new issue