Files
Home-AssistantConfig/deps/sqlalchemy/sql/__pycache__/base.cpython-34.pyc

220 lines
24 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
|<7C><>W<EFBFBD>Q<00>@s<>dZddlmZmZddlZddlmZddlZddlZej d<00>Z
ej d<00>Z Gd d
<00>d
e <00>Z d d <00>Zejd d<00><00>ZGdd<00>dej<00>ZGdd<00>dej<00>ZGdd<00>de <00>ZGdd<00>de <00>ZGdd<00>de<00>ZGdd<00>de <00>ZGdd<00>de<00>ZGdd<00>dej<00>ZGdd <00>d eje<00>ZGd!d"<00>d"ej<00>Zdd#d$<00>ZdS)%z4Foundational utilities common to many sql modules.
<EFBFBD>)<02>util<69>exc<78>N<>)<01> ClauseVisitor<6F>PARSE_AUTOCOMMIT<49>NO_ARGc@s:eZdZdZdd<00>Zdd<00>Zdd<00>ZdS) <09> Immutablez@mark a ClauseElement as 'immutable' when expressions are cloned.cOstd<00><00>dS)Nz(Immutable objects do not support copying)<01>NotImplementedError)<03>self<6C> optionaldict<63>kwargs<67>r<00>9/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/sql/base.py<70> unique_paramsszImmutable.unique_paramscOstd<00><00>dS)Nz(Immutable objects do not support copying)r
)r r r rrr<00>paramsszImmutable.paramscCs|S)Nr)r rrr<00>_clone szImmutable._cloneN)<07>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rrrrrrrr s   r cGstjdd<00>|D<><00>S)NcSsg|]}|j<00>qSr)<01> _from_objects)<02>.0<EFBFBD>elementrrr<00>
<listcomp>%s z!_from_objects.<locals>.<listcomp>)<02> itertools<6C>chain)<01>elementsrrrr$srcOs.|dj<00>}|||dd<00>|<00>|S)zMark a method as generative.rrN)<01> _generate)<04>fn<66>args<67>kwr rrr<00> _generative(sr"c@sjeZdZdZdd<00>Zdd<00>Zdd<00>Zdd <00>Zd
d <00>Zd d <00>Z dd<00>Z
dS)<11>_DialectArgViewzaA dictionary view of dialect-level arguments in the form
<dialectname>_<argument_name>.
cCs ||_dS)N)<01>obj)r r$rrr<00>__init__7sz_DialectArgView.__init__c CsKy|jdd<00>\}}Wntk
r<t|<00><00>Yn X||fSdS)N<>_r)<03>split<69>
ValueError<EFBFBD>KeyError)r <00>key<65>dialect<63> value_keyrrr<00>_key:s
 z_DialectArgView._keyc CsY|j|<00>\}}y|jj|}Wn!tjk
rLt|<00><00>Yn X||SdS)N)r-r$<00>dialect_optionsr<00>NoSuchModuleErrorr))r r*r+r,<00>optrrr<00> __getitem__Bs z_DialectArgView.__getitem__c CsUy|j|<00>\}}Wn!tk
r<tjd<00><00>YnX||jj||<dS)Nz0Keys must be of the form <dialectname>_<argname>)r-r)r<00> ArgumentErrorr$r.)r r*<00>valuer+r,rrr<00> __setitem__Ls  z_DialectArgView.__setitem__cCs*|j|<00>\}}|jj||=dS)N)r-r$r.)r r*r+r,rrr<00> __delitem__Usz_DialectArgView.__delitem__cCs#tdd<00>|jjj<00>D<><00>S)Ncss|]}t|j<00>VqdS)N)<02>len<65> _non_defaults)rr rrr<00> <genexpr>Zsz*_DialectArgView.__len__.<locals>.<genexpr>)<04>sumr$r.<00>values)r rrr<00>__len__Ys z_DialectArgView.__len__cs<00>fdd<00><00>jjD<>S)Nc3sB|]8}<00>jj|jD]}tjd||f<16>VqqdS)z%s_%sN)r$r.r7rZ
safe_kwarg)r<00> dialect_nameZ
value_name)r rrr8_sz+_DialectArgView.__iter__.<locals>.<genexpr>)r$r.)r r)r r<00>__iter__]sz_DialectArgView.__iter__N) rrrrr%r-r1r4r5r;r=rrrrr#1s   
 r#c@s^eZdZdZdd<00>Zdd<00>Zdd<00>Zdd <00>Zd
d <00>Zd d <00>Z dS)<0F>_DialectArgDictz<74>A dictionary view of dialect-level arguments for a specific
dialect.
Maintains a separate collection of user-specified arguments
and dialect-specified default arguments.
cCsi|_i|_dS)N)r7<00> _defaults)r rrrr%os z_DialectArgDict.__init__cCstt|j<00>j|j<00><00>S)N)r6<00>setr7<00>unionr?)r rrrr;ssz_DialectArgDict.__len__cCstt|j<00>j|j<00><00>S)N)<05>iterr@r7rAr?)r rrrr=vsz_DialectArgDict.__iter__cCs)||jkr|j|S|j|SdS)N)r7r?)r r*rrrr1ys z_DialectArgDict.__getitem__cCs||j|<dS)N)r7)r r*r3rrrr4sz_DialectArgDict.__setitem__cCs|j|=dS)N)r7)r r*rrrr5<00>sz_DialectArgDict.__delitem__N)
rrrrr%r;r=r1r4r5rrrrr>fs      r>c@s<>eZdZdZedd<00><00>Zejdd<00><00>Ze dd<00><00>Z
ej d<00>d d
<00><00>Z ej e <00>Zd d <00>Zejd d<00><00>Zdd<00>ZdS)<12> DialectKWArgsa9Establish the ability for a class to have dialect-specific arguments
with defaults and constructor validation.
The :class:`.DialectKWArgs` interacts with the
:attr:`.DefaultDialect.construct_arguments` present on a dialect.
.. seealso::
:attr:`.DefaultDialect.construct_arguments`
cCsZtj|}|dkr/tjd|<16><00>n||krHi||<n||||<dS)a<>Add a new kind of dialect-specific keyword argument for this class.
E.g.::
Index.argument_for("mydialect", "length", None)
some_index = Index('a', 'b', mydialect_length=5)
The :meth:`.DialectKWArgs.argument_for` method is a per-argument
way adding extra arguments to the
:attr:`.DefaultDialect.construct_arguments` dictionary. This
dictionary provides a list of argument names accepted by various
schema-level constructs on behalf of a dialect.
New dialects should typically specify this dictionary all at once as a
data member of the dialect class. The use case for ad-hoc addition of
argument names is typically for end-user code that is also using
a custom compilation scheme which consumes the additional arguments.
:param dialect_name: name of a dialect. The dialect must be
locatable, else a :class:`.NoSuchModuleError` is raised. The
dialect must also include an existing
:attr:`.DefaultDialect.construct_arguments` collection, indicating
that it participates in the keyword-argument validation and default
system, else :class:`.ArgumentError` is raised. If the dialect does
not include this collection, then any keyword argument can be
specified on behalf of this dialect already. All dialects packaged
within SQLAlchemy include this collection, however for third party
dialects, support may vary.
:param argument_name: name of the parameter.
:param default: default value of the parameter.
.. versionadded:: 0.9.4
NzRDialect '%s' does have keyword-argument validation and defaults enabled configured)rC<00> _kw_registryrr2)<05>clsr<Z argument_name<6D>default<6C>construct_arg_dictionaryrrr<00> argument_for<6F>s(     zDialectKWArgs.argument_forcCs
t|<00>S)a9A collection of keyword arguments specified as dialect-specific
options to this construct.
The arguments are present here in their original ``<dialect>_<kwarg>``
format. Only arguments that were actually passed are included;
unlike the :attr:`.DialectKWArgs.dialect_options` collection, which
contains all options known by this dialect including defaults.
The collection is also writable; keys are accepted of the
form ``<dialect>_<kwarg>`` where the value will be assembled
into the list of options.
.. versionadded:: 0.9.2
.. versionchanged:: 0.9.4 The :attr:`.DialectKWArgs.dialect_kwargs`
collection is now writable.
.. seealso::
:attr:`.DialectKWArgs.dialect_options` - nested dictionary form
)r#)r rrr<00>dialect_kwargs<67>szDialectKWArgs.dialect_kwargscCs|jS)z4A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.)rI)r rrrr <00>szDialectKWArgs.kwargszsqlalchemy.dialectscCs2|jj|<00>}|jdkr%dSt|j<00>S)N)<04>registry<72>loadZconstruct_arguments<74>dict)Zdialectsr<Z dialect_clsrrr<00>_kw_reg_for_dialect<63>sz!DialectKWArgs._kw_reg_for_dialectcCs<>tj|}t<00>}|dkr<|jjidd6<>n@x=t|jj<00>D])}||krO|jj||<19>qOqOW|S)N<>*)rCrDr>r?<00>update<74>reversed<65> __class__<5F>__mro__)r r<rG<00>drErrr<00>_kw_reg_for_dialect_cls<6C>s    z%DialectKWArgs._kw_reg_for_dialect_clscCstjtj|j<00><00>S)a<>A collection of keyword arguments specified as dialect-specific
options to this construct.
This is a two-level nested registry, keyed to ``<dialect_name>``
and ``<argument_name>``. For example, the ``postgresql_where``
argument would be locatable as::
arg = my_object.dialect_options['postgresql']['where']
.. versionadded:: 0.9.2
.. seealso::
:attr:`.DialectKWArgs.dialect_kwargs` - flat dictionary form
)r<00> PopulateDictZportable_instancemethodrT)r rrrr.<00>szDialectKWArgs.dialect_optionscCs&|s
dSx|D] }tjd|<00>}|sBtd|<16><00>n|jdd<00>\}}y|j|}Wnhtjk
r<>tjd||f<16>t <00>|j|<}|j
j idd6<>|||j |<YqXd|kr||krtj d|||jf<16><00>q||||<qWdS)Nz ^(.+?)_(.+)$zGAdditional arguments should be named <dialectname>_<argument>, got '%s'rrzHCan't validate argument %r; can't locate any SQLAlchemy dialect named %rrNz9Argument %r is not accepted by dialect %r on behalf of %r)<0F>re<72>match<63> TypeError<6F>groupr.rr/r<00>warnr>r?rOr7r2rQ)r r <00>k<>mr<Zarg_namerGrSrrr<00>_validate_dialect_kwargss2    z&DialectKWArgs._validate_dialect_kwargsN)rrrr<00> classmethodrHr<00>memoized_propertyrI<00>propertyr <00> dependenciesrMrUrDrTr.r]rrrrrC<00>s 2 rCc@s"eZdZdZdd<00>ZdS)<05>
GenerativezRAllow a ClauseElement to generate itself via the
@_generative decorator.
cCs+|jj|j<00>}|jj<00>|_|S)N)rQ<00>__new__<5F>__dict__<5F>copy)r <00>srrrr:szGenerative._generateN)rrrrrrrrrrb4s rbc@sjeZdZdZdZej<00>ZdZe dd<00><00>Z
dd<00>Z dd <00>Z e d
d <00><00>ZdS) <0C>
Executablez<EFBFBD>Mark a ClauseElement as supporting execution.
:class:`.Executable` is a superclass for all "statement" types
of objects, including :func:`select`, :func:`delete`, :func:`update`,
:func:`insert`, :func:`text`.
TNcKsUd|krtjd<00><00>nd|kr<tjd<00><00>n|jj|<00>|_dS)a0 Set non-SQL options for the statement which take effect during
execution.
Execution options can be set on a per-statement or
per :class:`.Connection` basis. Additionally, the
:class:`.Engine` and ORM :class:`~.orm.query.Query` objects provide
access to execution options which they in turn configure upon
connections.
The :meth:`execution_options` method is generative. A new
instance of this statement is returned that contains the options::
statement = select([table.c.x, table.c.y])
statement = statement.execution_options(autocommit=True)
Note that only a subset of possible execution options can be applied
to a statement - these include "autocommit" and "stream_results",
but not "isolation_level" or "compiled_cache".
See :meth:`.Connection.execution_options` for a full list of
possible options.
.. seealso::
:meth:`.Connection.execution_options()`
:meth:`.Query.execution_options()`
Zisolation_levelz<6C>'isolation_level' execution option may only be specified on Connection.execution_options(), or per-engine using the isolation_level argument to create_engine().Zcompiled_cachezm'compiled_cache' execution option may only be specified on Connection.execution_options(), not per statement.N)rr2<00>_execution_optionsrA)r r!rrr<00>execution_optionsMs    zExecutable.execution_optionscOs\|j}|dkrIt|d|jj<00>}d|}tj|<00><00>n|j|||<00>S)z.Compile and execute this :class:`.Executable`.N<> descriptionz<6E>This %s is not directly bound to a Connection or Engine.Use the .execute() method of a Connection or Engine to execute this construct.)<07>bind<6E>getattrrQrr<00>UnboundExecutionErrorZ_execute_clauseelement)r <00> multiparamsr<00>e<>label<65>msgrrr<00>executeys  zExecutable.executecOs|j||<00>j<00>S)znCompile and execute this :class:`.Executable`, returning the
result's scalar representation.
)rr<00>scalar)r rnrrrrrs<00>szExecutable.scalarcCs`|jdk r|jSxCt|<00>D]1}||kr;q#n|j}|dk r#|Sq#WdSdS)a5Returns the :class:`.Engine` or :class:`.Connection` to
which this :class:`.Executable` is bound, or None if none found.
This is a traversal which checks locally, then
checks among the "from" clauses of associated objects
until a bound engine or connection is found.
N)<03>_bindrrk)r <00>fZenginerrrrk<00>s
   zExecutable.bind)rrrrZsupports_executionrZ immutabledictrhrtr"rirrrsr`rkrrrrrg@s  , rgc@s.eZdZdZdd<00>Zdd<00>ZdS)<07>SchemaEventTargetz<74>Base class for elements that are the targets of :class:`.DDLEvents`
events.
This includes :class:`.SchemaItem` as well as :class:`.SchemaType`.
cCs t<00><00>dS)z0Associate with this SchemaEvent's parent object.N)r
)r <00>parentrrr<00> _set_parent<6E>szSchemaEventTarget._set_parentcCs7|jj||<00>|j|<00>|jj||<00>dS)N)<04>dispatchZbefore_parent_attachrxZafter_parent_attach)r rwrrr<00>_set_parent_with_dispatch<63>s z+SchemaEventTarget._set_parent_with_dispatchN)rrrrrxrzrrrrrv<00>s  rvc@s#eZdZdZidd6ZdS)<05> SchemaVisitorz/Define the visiting for ``SchemaItem`` objects.TZschema_visitorN)rrrrZ__traverse_options__rrrrr{<00>s r{cseZdZdZdZ<00>fdd<00>Zdd<00>Zdd<00>Zd d
<00>Zd d <00>Z d d<00>Z
dd<00>Z dd<00>Z dd<00>Z dd<00>Zdd<00>ZdZejd<00>dd<00><00>Zdd<00>Zdd <00>Zd!d"<00>Zd#d$<00>Zd%d&<00>Z<00>S)'<27>ColumnCollectionz<6E>An ordered dictionary that stores a list of ColumnElement
instances.
Overrides the ``__eq__()`` method to produce SQL clauses between
sets of correlated columns.
<20> _all_columnscsHtt|<00>j<00>tj|dg<00>x|D]}|j|<00>q-WdS)Nr})<06>superr|r%<00>object<63> __setattr__<5F>add)r <00>columns<6E>c)rQrrr%<00>s zColumnCollection.__init__cCstdd<00>|D<><00>S)NcSsg|]}t|<00><00>qSr)<01>str)rr<>rrrr<00>s z,ColumnCollection.__str__.<locals>.<listcomp>)<01>repr)r rrr<00>__str__<5F>szColumnCollection.__str__cs<>d<00><00>j|kr_<00>j<00>jkr_|<00>j}|j|jkr_|<00>|j|j=q_n<00>j|jkr<>|j<00>j<19>n<00>|j<00>j<<3C>dk r<><00><00>fdd<00>|jD<>|jdd<00><n|jj<00><00>dS)aadd the given column to this collection, removing unaliased
versions of this column as well as existing columns with the
same key.
e.g.::
t = Table('sometable', metadata, Column('col1', Integer))
t.columns.replace(Column('col1', Integer, key='columnone'))
will remove the original 'col1' from the collection, and add
the new column under the name 'columnname'.
Used by schema.Column to override columns during table reflection.
Ncs(g|]}|<00>kr<00>n|<00>qSrr)rr<>)<02>column<6D>
remove_colrrr<00>s z,ColumnCollection.replace.<locals>.<listcomp>)<05>namer*<00>_datar}<00>append)r r<><00>otherr)r<>r<>r<00>replace<63>s!  zColumnCollection.replacecCs,|jstjd<00><00>n|||j<dS)z<>Add a column to this collection.
The key attribute of the column will be used as the hash key
for this dictionary.
z-Can't add unnamed column to column collectionN)r*rr2)r r<>rrrr<><00>s  zColumnCollection.addcCs t<00><00>dS)N)r
)r r*rrrr5<00>szColumnCollection.__delitem__cCs t<00><00>dS)N)r
)r r*rrrrr<><00>szColumnCollection.__setattr__cCs<>||krd||}|j|<00>sNtjd|t|dd<00>|f<16>ntjj|d<00>n|jj|<00>||j|<dS)NzqColumn %r on table %r being replaced by %r, which has the same key. Consider use_labels for select() statements.<2E>tableZ proxy_set) <09>shares_lineagerrZrlr_<00>resetr}r<>r<>)r r*r3<00>existingrrrr4s 
  zColumnCollection.__setitem__cCs t<00><00>dS)N)r
)r rrr<00>clearszColumnCollection.clearcs:|j<00>j=<3D>fdd<00>|jD<>|jdd<00><dS)Ncs"g|]}|<00>k r|<00>qSrr)rr<>)r<>rrrs z+ColumnCollection.remove.<locals>.<listcomp>)r<>r*r})r r<>r)r<>r<00>removes zColumnCollection.removecs_t|<00>}t|j<00><00>|jj<00>fdd<00>|D<><00>|jjdd<00>|D<><00>dS)Nc3s'|]\}}|<00>kr|VqdS)Nr)rrpr<>)<01> all_col_setrrr8$sz*ColumnCollection.update.<locals>.<genexpr>css!|]\}}||fVqdS)Nr)rrpr<>rrrr8%s)<06>listr@r}<00>extendr<64>rO)r rB<00>colsr)r<>rrO s
  zColumnCollection.updatecs_t|<00>}t|j<00><00>|jj<00>fdd<00>|D<><00>|jjdd<00>|D<><00>dS)Nc3s!|]}|<00>kr|VqdS)Nr)rr<>)r<>rrr8*sz*ColumnCollection.extend.<locals>.<genexpr>css|]}|j|fVqdS)N)r*)rr<>rrrr8+s)r<>r@r}r<>r<>rO)r rBr<>r)r<>rr<>'s #zColumnCollection.extendNzsqlalchemy.sql.elementscCsig}xSt|d|<00>D]?}x6|jD]+}|j|<00>r)|j||k<00>q)q)WqW|j|<00>S)Nr})rlr}r<>r<><00>and_)r rr<><00>lr<6C><00>localrrr<00>__eq__/s zColumnCollection.__eq__cCs7t|tj<00>s$tjd<00><00>ntjj||<00>S)Nz'__contains__ requires a string argument)<07>
isinstancer<00> string_typesrr2<00>OrderedProperties<65> __contains__)r r<>rrrr<>8szColumnCollection.__contains__cCsi|jd6|jd6S)Nr<4E>r})r<>r})r rrr<00> __getstate__=s zColumnCollection.__getstate__cCs2tj|d|d<19>tj|d|d<19>dS)Nr<4E>r})rr<>)r <00>staterrr<00> __setstate__AszColumnCollection.__setstate__cCs|t|j<00>kS)N)r@r})r <00>colrrr<00>contains_columnEsz ColumnCollection.contains_columncCst|j|j<00>S)N)<03>ImmutableColumnCollectionr<6E>r})r rrr<00> as_immutableHszColumnCollection.as_immutable)rrrr<00> __slots__r%r<>r<>r<>r5r<>r4r<>r<>rOr<><00>__hash__rrar<>r<>r<>r<>r<>r<>rr)rQrr|<00>s(   !           r|c@s,eZdZdd<00>ZejjZZdS)r<>cCs*tjj||<00>tj|d|<00>dS)Nr})r<00>ImmutablePropertiesr%rr<>)r <00>dataZ all_columnsrrrr%Msz"ImmutableColumnCollection.__init__N) rrrr%rr<>Z
_immutabler<EFBFBD>r<>rrrrr<>Ls  r<>c@s[eZdZdd<00>Zdd<00>Zdd<00>Zejd<00>dd <00><00>Zd
d <00>Z d S) <0A> ColumnSetcCs
||kS)Nr)r r<>rrrr<>UszColumnSet.contains_columncCs"x|D]}|j|<00>qWdS)N)r<>)r r<>r<>rrrr<>Xs zColumnSet.extendcCst|<00>t|<00>S)N)r<>)r r<>rrr<00>__add__\szColumnSet.__add__zsqlalchemy.sql.elementscCsZg}xD|D]<}x3|D]+}|j|<00>r|j||k<00>qqWq W|j|<00>S)N)r<>r<>r<>)r rr<>r<>r<>r<>rrrr<>_s   zColumnSet.__eq__cCsttdd<00>|D<><00><00>S)Ncss|] }|VqdS)Nr)r<00>xrrrr8isz%ColumnSet.__hash__.<locals>.<genexpr>)<02>hash<73>tuple)r rrrr<>hszColumnSet.__hash__N)
rrrr<>r<>r<>rrar<>r<>rrrrr<>Ts
    r<>cCs<>|j}|s<>|jj}t|dt|dd<00><00>}|rRd||f}n
d|}|dkrud|}ntj|<00><00>n|S)N<>fullnamer<65>z %s object %rz %s objectzm%s is not bound to an Engine or Connection. Execution can not proceed without a database to execute against.)rkrQrrlrrm)Z
schemaitemrqrkr<>rp<00>itemrrr<00>_bind_or_errorls   
 
r<>) r<00>rrrZvisitorsrrV<00> collections<6E>symbolrrrr rZ decoratorr"<00>MutableMappingr#r>rCrbrgrvr{r<>r|r<>r<>Zordered_column_setr<74>r<>rrrr<00><module>
s*     5 <16> b<19>