File: //opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/__pycache__/visitors.cpython-37.pyc
B
��4]( � @ s� d Z ddlmZ ddlZddlmZ ddlmZ ddd d
ddd
dddddgZG dd� de�Z dd� Z
G dd� de�e e��Z
G dd � d e�ZG dd
� d
e�ZG dd� de�Zdd� Zdd
� Zdd� Zdd� Zdd� Zdd� Zd d� ZdS )!aO Visitor/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/
� )�dequeN� )�exc)�util�
VisitableType� Visitable�
ClauseVisitor�CloningVisitor�ReplacingCloningVisitor�iterate�iterate_depthfirst�traverse_using�traverse�traverse_depthfirst�cloned_traverse�replacement_traversec s e Zd ZdZ� fdd�Z� ZS )r ae Metaclass 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.
c s2 |dkrt | d�rt| � tt| ��|||� d S )Nr �__visit_name__)�hasattr�_generate_dispatch�superr �__init__)�clsZclsname�basesZclsdict)� __class__� �J/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/sql/visitors.pyr B s zVisitableType.__init__)�__name__�
__module__�__qualname__�__doc__r �
__classcell__r r )r r r 2 s c sT d� j krP� j}t|t�r8t�d| ��� �fdd�}n� fdd�}d|_|� _dS )zYReturn an optimized visit dispatch function for the cls
for use by the compiler.
r zvisit_%sc s>