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

108 lines
11 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
|<7C><>W(<00> @sJdZddlmZddlmZddlZddlmZddd d
d d d dddddg ZGdd<00>de<00>Z dd<00>Z
Gdd<00>dej e e <00><00>Z Gdd <00>d e <00>ZGdd
<00>d
e<00>ZGdd <00>d e<00>Zdd <00>Zdd <00>Zdd<00>Zdd<00>Zdd<00>Zdd<00>Zd d<00>ZdS)!aOVisitor/traversal interface and library functions.
SQLAlchemy schema and expression constructs rely on a Python-centric
version of the classic "visitor" pattern as the primary way in which
they apply functionality. The most common use of this pattern
is statement compilation, where individual expression classes match
up to rendering methods that produce a string result. Beyond this,
the visitor system is also used to inspect expressions for various
information and patterns, as well as for usage in
some kinds of expression transformation. Other kinds of transformation
use a non-visitor traversal system.
For many examples of how the visit system is used, see the
sqlalchemy.sql.util and the sqlalchemy.sql.compiler modules.
For an introduction to clause adaption, see
http://techspot.zzzeek.org/2008/01/23/expression-transformations/
<EFBFBD>)<01>deque<75>)<01>utilN)<01>exc<78> VisitableType<70> Visitable<6C> ClauseVisitor<6F>CloningVisitor<6F>ReplacingCloningVisitor<6F>iterate<74>iterate_depthfirst<73>traverse_using<6E>traverse<73>traverse_depthfirst<73>cloned_traverse<73>replacement_traversecs(eZdZdZ<00>fdd<00>Z<00>S)raeMetaclass which assigns a `_compiler_dispatch` method to classes
having a `__visit_name__` attribute.
The _compiler_dispatch attribute becomes an instance method which
looks approximately like the following::
def _compiler_dispatch (self, visitor, **kw):
'''Look for an attribute named "visit_" + self.__visit_name__
on the visitor, and call it with the same kw params.'''
visit_attr = 'visit_%s' % self.__visit_name__
return getattr(visitor, visit_attr)(self, **kw)
Classes having no __visit_name__ attribute will remain unaffected.
csH|dkr(t|d<00>r(t|<00>ntt|<00>j|||<00>dS)Nr<00>__visit_name__)<05>hasattr<74>_generate_dispatch<63>superr<00>__init__)<04>clsZclsname<6D>basesZclsdict)<01> __class__<5F><00>=/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/sql/visitors.pyr7s  zVisitableType.__init__)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rrr)rrr's cs}d<00>jkry<00>j}t|t<00>rRtjd|<16><00><00><00>fdd<00>}n<00>fdd<00>}d|_|<00>_ndS)zYReturn an optimized visit dispatch function for the cls
for use by the compiler.
rzvisit_%sc sHy<00>|<00>}Wn$tk
r6tj|<00><00><00>YnX|||<00>SdS)N)<03>AttributeErrorr<00>UnsupportedCompilationError)<04>self<6C>visitor<6F>kw<6B>meth)r<00>getterrr<00>_compiler_dispatchKs
 z._generate_dispatch.<locals>._compiler_dispatchc sXd|j}yt||<00>}Wn$tk
rFtj|<00><00><00>YnX|||<00>SdS)Nzvisit_%s)r<00>getattrr rr!)r"r#r$Z
visit_attrr%)rrrr'Vs   z<>Look for an attribute named "visit_" + self.__visit_name__
on the visitor, and call it with the same kw params.
N)<08>__dict__r<00>
isinstance<EFBFBD>str<74>operator<6F>
attrgetterrr')rZ
visit_namer'r)rr&rr?s   rc@seZdZdZdS)rzTBase class for visitable objects, applies the
``VisitableType`` metaclass.
N)rrrrrrrrrfs c@sseZdZdZiZdd<00>Zdd<00>Zdd<00>Zej dd <00><00>Z
e d
d <00><00>Z d d <00>Z dS)rzZBase class for visitor objects which can traverse using
the traverse() function.
cKsDx=|jD]2}t|d|jd<00>}|r
|||<00>Sq
WdS)Nzvisit_%s)<03>_visitor_iteratorr(r)r"<00>objr$<00>vr%rrr<00>traverse_singleuszClauseVisitor.traverse_singlecCst||j<00>S)zatraverse the given expression structure, returning an iterator
of all elements.
)r <00>__traverse_options__)r"r/rrrr {szClauseVisitor.iteratecCst||j|j<00>S)z2traverse and visit the given expression structure.)rr2<00> _visitor_dict)r"r/rrrr<00>szClauseVisitor.traversecCsPi}xCt|<00>D]5}|jd<00>rt||<00>||dd<00><qqW|S)NZvisit_<74>)<03>dir<69>
startswithr()r"<00>visitors<72>namerrrr3<00>s
$zClauseVisitor._visitor_dictccs.|}x!|r)|Vt|dd<00>}q WdS)z8iterate through this visitor and each 'chained' visitor.<2E>_nextN)r()r"r0rrrr.<00>s zClauseVisitor._visitor_iteratorcCs t|j<00>d}||_|S)z<>'chain' an additional ClauseVisitor onto this ClauseVisitor.
the chained visitor will receive all visit events after this one.
<20><00><><EFBFBD><EFBFBD><EFBFBD>)<03>listr.r9)r"r#<00>tailrrr<00>chain<69>s zClauseVisitor.chainN)rrrrr2r1r rrZmemoized_propertyr3<00>propertyr.r>rrrrrms      c@s.eZdZdZdd<00>Zdd<00>ZdS)r zaBase class for visitor objects which can traverse using
the cloned_traverse() function.
cs<00>fdd<00>|D<>S)z`Apply cloned traversal to the given list of elements, and return
the new list.
csg|]}<00>j|<00><00>qSr)r)<02>.0<EFBFBD>x)r"rr<00>
<listcomp><3E>s z3CloningVisitor.copy_and_process.<locals>.<listcomp>r)r"Zlist_r)r"r<00>copy_and_process<73>szCloningVisitor.copy_and_processcCst||j|j<00>S)z2traverse and visit the given expression structure.)rr2r3)r"r/rrrr<00>szCloningVisitor.traverseN)rrrrrCrrrrrr <00>s  c@s.eZdZdZdd<00>Zdd<00>ZdS)r
zfBase class for visitor objects which can traverse using
the replacement_traverse() function.
cCsdS)areceive pre-copied elements during a cloning traversal.
If the method returns a new element, the element is used
instead of creating a simple copy of the element. Traversal
will halt on the newly returned element if it is re-encountered.
Nr)r"<00>elemrrr<00>replace<63>szReplacingCloningVisitor.replacecs%<00>fdd<00>}t|<00>j|<00>S)z2traverse and visit the given expression structure.cs7x0<00>jD]%}|j|<00>}|dk r
|Sq
WdS)N)r.rE)rDr0<00>e)r"rrrE<00>s z1ReplacingCloningVisitor.traverse.<locals>.replace)rr2)r"r/rEr)r"rr<00>sz ReplacingCloningVisitor.traverseN)rrrrrErrrrrr
<00>s  cCs<>|j|<00>}|s|gSt<00>}t|g<00>}xJ|r<>|j<00>}|j|<00>x$|j|<00>D]}|j|<00>qfWq7Wt|<00>S)zwtraverse the given expression structure, returning an iterator.
traversal is configured to be breadth-first.
)<05> get_childrenr<00>popleft<66>append<6E>iter)r/<00>opts<74>children<65> traversal<61>stack<63>t<>crrrr <00>s    cCs<>|j|<00>}|s|gSt|g<00>}t<00>}xJ|r<>|j<00>}|j|<00>x$|j|<00>D]}|j|<00>qfWq7Wt|<00>S)zutraverse the given expression structure, returning an iterator.
traversal is configured to be depth-first.
)rGr<00>pop<6F>
appendleftrIrJ)r/rKrLrNrMrOrPrrrr <00>s    cCs=x6|D].}|j|jd<00>}|r||<00>qqW|S)zSvisit the given expression structure using the given iterator of
objects.
N)<02>getr)<05>iteratorr/r7<00>targetr%rrrr <00>s
 cCstt||<00>||<00>S)zXtraverse and visit the given expression structure using the default
iterator.
)r r )r/rKr7rrrrscCstt||<00>||<00>S)z[traverse and visit the given expression structure using the
depth-first iterator.
)r r )r/rKr7rrrrscsXi<00>t|jdg<00><00><00><00><00><00><00>fdd<00><00>|dk rT<00>|<00>}n|S)zMclone the given expression structure, allowing
modifications by visitors.<2E>stop_oncs<>|<00>kr|St|<00><00>krw|j<00><04>t|<00><}|jd<00><00><01>j|jd<00>}|rw||<00>qwn<00>t|<00>SdS)N<>clone)<05>id<69>_clone<6E>_copy_internalsrSr)rD<00>newelemr%)rW<00>clonedrVr7rrrWs zcloned_traverse.<locals>.cloneN)<02>setrS)r/rKr7r)rWr\rVr7rrs  cshi<00>tdd<00>|jdg<00>D<><00><00><00><00><00><00>fdd<00><00>|dk rd<00>||<00>}n|S)zgclone the given expression structure, allowing element
replacement by a given replacement function.cSsg|]}t|<00><00>qSr)rX)r@rArrrrB5s z(replacement_traverse.<locals>.<listcomp>rVcs<>t|<00><00>ks!d|jkr%|S<>|<00>}|dk rT<00>jt|<00><00>|S|<00>kr<>|j<00><04>|<}|jd<00>|<00>n<00>|SdS)NZno_replacement_traverserW)rXZ _annotations<6E>addrYrZ)rDr$r[)rWr\rErVrrrW7s   z#replacement_traverse.<locals>.cloneN)r]rS)r/rKrEr)rWr\rErVrr0s % )r<00> collectionsr<00>rr,r<00>__all__<5F>typerr<00>with_metaclass<73>objectrrr r
r r r rrrrrrrr<00><module>s,      '"7