Files
Home-AssistantConfig/deps/sqlalchemy/dialects/postgresql/__pycache__/hstore.cpython-34.pyc

172 lines
13 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
}<7D><>W<EFBFBD>,<00>@s<>ddlZddlmZmZddlmZddlmZ ddl
m Z ddlm Z d#Z ejd ej<00>Zejd ej<00>Zd d<00>Zdd<00>Zdd<00>ZGdd <00>d ejej<00>Zeed
<Gdd
<00>d
e j<00>ZGdd<00>de j<00>ZGdd<00>de j<00>ZGdd<00>de j<00>ZGdd<00>de j<00>ZGdd<00>de j<00>ZGdd <00>d e j<00>ZGd!d"<00>d"e j<00>Z dS)$<24>N<>)<02>ARRAY<41> ischema_names<65>)<01>types)<01> functions)<01> custom_op)<01>util<69>HSTORE<52>hstorez<65>
(
"(?P<key> (\\ . | [^"])* )" # Quoted key
)
[ ]* => [ ]* # Pair operator, optional adjoining whitespace
(
(?P<value_null> NULL ) # NULL value
| "(?P<value> (\\ . | [^"])* )" # Quoted value
)
z
[ ]* , [ ]*
cCs<>d}t|<00>}|t||dd<00>t||<00><00>}|t||<00>t||d|<00><00>}t|<00>|kr<>d|dd<00>}nt|<00>|kr<>|dd<00>d}nd|||fS)zformat an unmarshalling error.<2E>rrz[...]Nz5After %r, could not parse residual at position %d: %r<><72><EFBFBD><EFBFBD><EFBFBD>)<03>len<65>max<61>min)<06>
hstore_str<EFBFBD>pos<6F>ctxZhslenZ parsed_tailZresidual<61>r<00>K/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/dialects/postgresql/hstore.py<70> _parse_error%s **rcCs-i}d}tj|<00>}x<>|dk r<>|jd<00>jdd<00>jdd<00>}|jd<00>rid}n'|jd <00>jdd<00>jdd<00>}|||<||j<00>7}tj||d<00><19>}|dk r<>||j<00>7}ntj||d<00><19>}qW|t|<00>kr)tt||<00><00><00>n|S)
a<EFBFBD>Parse an hstore from its literal string representation.
Attempts to approximate PG's hstore input parsing rules as closely as
possible. Although currently this is not strictly necessary, since the
current implementation of hstore's output syntax is stricter than what it
accepts as input, the documentation makes no guarantees that will always
be the case.
rN<>keyz\"<22>"z\\<5C>\Z
value_null<EFBFBD>value) <09>HSTORE_PAIR_RE<52>match<63>group<75>replace<63>end<6E>HSTORE_DELIMITER_REr<00>
ValueErrorr)r<00>resultrZ
pair_matchrrZ delim_matchrrr<00> _parse_hstore7s$   '
 r#cs2dd<00><00>dj<00>fdd<00>|j<00>D<><00>S)zxSerialize a dictionary into an hstore literal. Keys and values must
both be strings (except None for values).
cSsh|dkr|dkrdSt|tj<00>rNd|jdd<00>jdd<00>Std||f<16><00>dS) NrZNULLz"%s"rz\\rz\"z"%r in %s position is not a string.)<05>
isinstancer <00> string_typesrr!)<02>s<>positionrrr<00>escds  z_serialize_hstore.<locals>.escz, c3s7|]-\}}d<00>|d<00><00>|d<00>fVqdS)z%s=>%srrNr)<03>.0<EFBFBD>k<>v)r(rr<00> <genexpr>msz$_serialize_hstore.<locals>.<genexpr>)<02>join<69>items)<01>valr)r(r<00>_serialize_hstore_s r0c@sVeZdZdZdZdZGdd<00>dejj<00>Z dd<00>Z
dd<00>Z d S)
r
a<>Represent the Postgresql HSTORE type.
The :class:`.HSTORE` type stores dictionaries containing strings, e.g.::
data_table = Table('data_table', metadata,
Column('id', Integer, primary_key=True),
Column('data', HSTORE)
)
with engine.connect() as conn:
conn.execute(
data_table.insert(),
data = {"key1": "value1", "key2": "value2"}
)
:class:`.HSTORE` provides for a wide range of operations, including:
* Index operations::
data_table.c.data['some key'] == 'some value'
* Containment operations::
data_table.c.data.has_key('some key')
data_table.c.data.has_all(['one', 'two', 'three'])
* Concatenation::
data_table.c.data + {"k1": "v1"}
For a full list of special methods see
:class:`.HSTORE.comparator_factory`.
For usage with the SQLAlchemy ORM, it may be desirable to combine
the usage of :class:`.HSTORE` with :class:`.MutableDict` dictionary
now part of the :mod:`sqlalchemy.ext.mutable`
extension. This extension will allow "in-place" changes to the
dictionary, e.g. addition of new keys or replacement/removal of existing
keys to/from the current dictionary, to produce events which will be
detected by the unit of work::
from sqlalchemy.ext.mutable import MutableDict
class MyClass(Base):
__tablename__ = 'data_table'
id = Column(Integer, primary_key=True)
data = Column(MutableDict.as_mutable(HSTORE))
my_object = session.query(MyClass).one()
# in-place mutation, requires Mutable extension
# in order for the ORM to detect
my_object.data['some_key'] = 'some value'
session.commit()
When the :mod:`sqlalchemy.ext.mutable` extension is not used, the ORM
will not be alerted to any changes to the contents of an existing
dictionary, unless that dictionary value is re-assigned to the
HSTORE-attribute itself, thus generating a change event.
.. versionadded:: 0.8
.. seealso::
:class:`.hstore` - render the Postgresql ``hstore()`` function.
Fc@s<>eZdZdZdd<00>Zdd<00>Zdd<00>Zdd <00>Zd
d <00>Zd d <00>Z dd<00>Z
dd<00>Z dd<00>Z dd<00>Z dd<00>Zdd<00>Zdd<00>Zdd<00>ZdS)zHSTORE.comparator_factoryz2Define comparison operations for :class:`.HSTORE`.cCs|jjd<00>|<00>S)zvBoolean expression. Test for presence of a key. Note that the
key may be a SQLA expression.
<20>?)<02>expr<70>op)<02>self<6C>otherrrr<00>has_key<65>sz!HSTORE.comparator_factory.has_keycCs|jjd<00>|<00>S)z\Boolean expression. Test for presence of all keys in the PG
array.
z?&)r2r3)r4r5rrr<00>has_all<6C>sz!HSTORE.comparator_factory.has_allcCs|jjd<00>|<00>S)z[Boolean expression. Test for presence of any key in the PG
array.
z?|)r2r3)r4r5rrr<00>has_any<6E>sz!HSTORE.comparator_factory.has_anycCst|j|<00>S)z<>Boolean expression. Test for presence of a non-NULL value for
the key. Note that the key may be a SQLA expression.
)<02>_HStoreDefinedFunctionr2)r4rrrr<00>defined<65>sz!HSTORE.comparator_factory.definedcKs|jjd<00>|<00>S)zxBoolean expression. Test if keys are a superset of the keys of
the argument hstore expression.
z@>)r2r3)r4r5<00>kwargsrrr<00>contains<6E>sz"HSTORE.comparator_factory.containscCs|jjd<00>|<00>S)z}Boolean expression. Test if keys are a proper subset of the
keys of the argument hstore expression.
z<@)r2r3)r4r5rrr<00> contained_by<62>sz&HSTORE.comparator_factory.contained_bycCs|jjddd<00>|<00>S)zuText expression. Get the value at a given key. Note that the
key may be a SQLA expression.
z-><3E>
precedence<EFBFBD>)r2r3)r4r5rrr<00> __getitem__<5F>sz%HSTORE.comparator_factory.__getitem__cCs.t|t<00>rt|<00>}nt|j|<00>S)z<>HStore expression. Returns the contents of this hstore with the
given key deleted. Note that the key may be a SQLA expression.
)r$<00>dictr0<00>_HStoreDeleteFunctionr2)r4rrrr<00>delete<74>sz HSTORE.comparator_factory.deletecCst|j|<00>S)zdHStore expression. Returns a subset of an hstore defined by
array of keys.
)<02>_HStoreSliceFunctionr2)r4<00>arrayrrr<00>slice<63>szHSTORE.comparator_factory.slicecCs t|j<00>S)z.Text array expression. Returns array of keys.)<02>_HStoreKeysFunctionr2)r4rrr<00>keys<79>szHSTORE.comparator_factory.keyscCs t|j<00>S)z0Text array expression. Returns array of values.)<02>_HStoreValsFunctionr2)r4rrr<00>vals<6C>szHSTORE.comparator_factory.valscCs t|j<00>S)z^Text array expression. Returns array of alternating keys and
values.
)<02>_HStoreArrayFunctionr2)r4rrrrEszHSTORE.comparator_factory.arraycCs t|j<00>S)z<Text array expression. Returns array of [key, value] pairs.)<02>_HStoreMatrixFunctionr2)r4rrr<00>matrixsz HSTORE.comparator_factory.matrixcCsct|t<00>rJ|jdkr+|tjfS|jdkrJ|tjfSntjjj|||<00>S)Nr1<00>?&<26>?|<7C>@><3E><@z->)r1rNrOrPrQ) r$rZopstring<6E>sqltypes<65>Boolean<61>Text<78> Concatenable<6C>
Comparator<EFBFBD>_adapt_expression)r4r3Zother_comparatorrrrrW
s  z+HSTORE.comparator_factory._adapt_expressionN)<12>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r6r7r8r:r<r=r@rCrFrHrJrErMrWrrrr<00>comparator_factory<72>s              r\cs7tjr'|j<00><00>fdd<00>}n dd<00>}|S)Ncs*t|t<00>r"t|<00>j<00><00>S|SdS)N)r$rAr0<00>encode)r)<01>encodingrr<00>processsz&HSTORE.bind_processor.<locals>.processcSs!t|t<00>rt|<00>S|SdS)N)r$rAr0)rrrrr_s
)r <00>py2kr^)r4<00>dialectr_r)r^r<00>bind_processors
   zHSTORE.bind_processorcs7tjr'|j<00><00>fdd<00>}n dd<00>}|S)Ncs'|dk rt|j<00><00><00>S|SdS)N)r#<00>decode)r)r^rrr_(s z(HSTORE.result_processor.<locals>.processcSs|dk rt|<00>S|SdS)N)r#)rrrrr_.s 
)r r`r^)r4raZcoltyper_r)r^r<00>result_processor$s
   zHSTORE.result_processorN) rXrYrZr[Z__visit_name__ZhashablerRrUrVr\rbrdrrrrr
qs GV c@s"eZdZdZeZdZdS)r azConstruct an hstore value within a SQL expression using the
Postgresql ``hstore()`` function.
The :class:`.hstore` function accepts one or two arguments as described
in the Postgresql documentation.
E.g.::
from sqlalchemy.dialects.postgresql import array, hstore
select([hstore('key1', 'value1')])
select([
hstore(
array(['key1', 'key2', 'key3']),
array(['value1', 'value2', 'value3'])
)
])
.. versionadded:: 0.8
.. seealso::
:class:`.HSTORE` - the Postgresql ``HSTORE`` datatype.
N)rXrYrZr[r
<00>type<70>namerrrrr 9s c@seZdZejZdZdS)r9r:N)rXrYrZrRrSrerfrrrrr9Xs  r9c@seZdZeZdZdS)rBrCN)rXrYrZr
rerfrrrrrB]s rBc@seZdZeZdZdS)rDrFN)rXrYrZr
rerfrrrrrDbs rDc@s%eZdZeej<00>ZdZdS)rGZakeysN)rXrYrZrrRrTrerfrrrrrGgs rGc@s%eZdZeej<00>ZdZdS)rIZavalsN)rXrYrZrrRrTrerfrrrrrIls rIc@s%eZdZeej<00>ZdZdS)rKZhstore_to_arrayN)rXrYrZrrRrTrerfrrrrrKqs rKc@s%eZdZeej<00>ZdZdS)rLZhstore_to_matrixN)rXrYrZrrRrTrerfrrrrrLvs rL)zHSTOREzhstore)!<21>re<72>baserr<00>rrRZsqlrZsqlfuncZ sql.operatorsrr <00>__all__<5F>compile<6C>VERBOSErr rr#r0rUZ
TypeEnginer
ZGenericFunctionr r9rBrDrGrIrKrLrrrr<00><module>s.    ( <1F>