Hacked By AnonymousFox

Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/ast.cpython-33.pyo

�
��fn/c@s�dZddlTdddd�Zdd�Zdd d	d
�Zdd�Zd
d�Zddd�Z	dd�Z
dd�Zddd�Zdd�Z
Gdd�de�ZGdd�de�ZdS(!uH
    ast
    ~~~

    The `ast` module helps Python applications to process trees of the Python
    abstract syntax grammar.  The abstract syntax itself might change with
    each Python release; this module helps to find out programmatically what
    the current grammar looks like and allows modifications of it.

    An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
    a flag to the `compile()` builtin function or by using the `parse()`
    function from this module.  The result will be a tree of objects whose
    classes all inherit from `ast.AST`.

    A modified abstract syntax tree can be compiled into a Python code object
    using the built-in `compile()` function.

    Additionally various helper functions are provided that make working with
    the trees simpler.  The main intention of the helper functions and this
    module in general is to provide an easy to use interface for libraries
    that work tightly with the python syntax (template engines for example).


    :copyright: Copyright 2008 by Armin Ronacher.
    :license: Python License.
i(u*u	<unknown>uexeccCst|||t�S(un
    Parse the source into an AST node.
    Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
    (ucompileu
PyCF_ONLY_AST(usourceufilenameumode((u(/opt/alt/python33/lib64/python3.3/ast.pyuparsesuparsecsyidd6d	d6d
d6�t|t�r?t|dd�}nt|t�rZ|j}n��fdd���|�S(u
    Safely evaluate an expression node or a string containing a Python
    expression.  The string or node provided may only consist of the following
    Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
    sets, booleans, and None.
    uNoneuTrueuFalseumodeuevalc
s2t|ttf�r|jSt|t�r2|jSt|t�rWtt�|j	��St|t
�r|tt�|j	��St|t�r�t
t�|j	��St|t�r�t�fdd�t|j|j�D��St|t�r|j�kr�|jSnt|t�rxt|jttf�rxt|jtttf�rx�|j�}t|jt�rp|
S|Sn�t|t�rt|jttf�rt|jtttf�rt|jtttf�r�|j�}�|j�}t|jt�r
||S||Sntdt |���dS(Nc3s-|]#\}}�|��|�fVqdS(N((u.0ukuv(u_convert(u(/opt/alt/python33/lib64/python3.3/ast.pyu	<genexpr>>su1literal_eval.<locals>._convert.<locals>.<genexpr>umalformed node or string: (!u
isinstanceuStruBytesusuNumunuTupleutupleumapueltsuListulistuSetusetuDictudictuzipukeysuvaluesuNameuiduUnaryOpuopuUAdduUSubuoperanduBinOpuAdduSuburightuleftu
ValueErrorurepr(unodeuoperandulefturight(u_convertu_safe_names(u(/opt/alt/python33/lib64/python3.3/ast.pyu_convert2sBuliteral_eval.<locals>._convertNTF(uNoneuTrueuFalseu
isinstanceustruparseu
Expressionubody(unode_or_string((u_convertu_safe_namesu(/opt/alt/python33/lib64/python3.3/ast.pyuliteral_eval&s$uliteral_evalcsJ���fdd��t|t�s@td|jj��n�|�S(u�
    Return a formatted dump of the tree in *node*.  This is mainly useful for
    debugging purposes.  The returned string will show the names and the values
    for fields.  This makes the code impossible to evaluate, so if evaluation is
    wanted *annotate_fields* must be set to False.  Attributes such as line
    numbers and column offsets are not dumped by default.  If this is wanted,
    *include_attributes* can be set to True.
    cst�t�r��fdd�t��D�}d�jjdj�rYdd�|D�ndd�|D��f}�r��jr�||r�dp�d7}|dj��fd	d��jD��7}n|d
St�t�rddj�fdd��D��St��S(
Ncs(g|]\}}|�|�f�qS(((u.0uaub(u_format(u(/opt/alt/python33/lib64/python3.3/ast.pyu
<listcomp>ds	u)dump.<locals>._format.<locals>.<listcomp>u%s(%su, css|]}d|VqdS(u%s=%sN((u.0ufield((u(/opt/alt/python33/lib64/python3.3/ast.pyu	<genexpr>fsu(dump.<locals>._format.<locals>.<genexpr>css|]\}}|VqdS(N((u.0uaub((u(/opt/alt/python33/lib64/python3.3/ast.pyu	<genexpr>hsu c3s.|]$}d|�t�|��fVqdS(u%s=%sN(ugetattr(u.0ua(u_formatunode(u(/opt/alt/python33/lib64/python3.3/ast.pyu	<genexpr>lsu)u[%s]c3s|]}�|�VqdS(N((u.0ux(u_format(u(/opt/alt/python33/lib64/python3.3/ast.pyu	<genexpr>ps(	u
isinstanceuASTuiter_fieldsu	__class__u__name__ujoinu_attributesulisturepr(unodeufieldsurv(u_formatuannotate_fieldsuinclude_attributes(unodeu(/opt/alt/python33/lib64/python3.3/ast.pyu_formatbs$udump.<locals>._formatuexpected AST, got %r(u
isinstanceuASTu	TypeErroru	__class__u__name__(unodeuannotate_fieldsuinclude_attributes((u_formatuannotate_fieldsuinclude_attributesu(/opt/alt/python33/lib64/python3.3/ast.pyudumpYs	udumpc	Cs^xWdD]O}||jkr||jkrt||�rt||t||��qqW|S(u�
    Copy source location (`lineno` and `col_offset` attributes) from
    *old_node* to *new_node* if possible, and return *new_node*.
    ulinenou
col_offset(ulinenou
col_offset(u_attributesuhasattrusetattrugetattr(unew_nodeuold_nodeuattr((u(/opt/alt/python33/lib64/python3.3/ast.pyu
copy_locationws

 u
copy_locationcs&�fdd���|dd�|S(u{
    When you compile a node tree with compile(), the compiler expects lineno and
    col_offset attributes for every node that supports them.  This is rather
    tedious to fill in for generated nodes, so this helper adds these attributes
    recursively where not already set, by setting them to the values of the
    parent node.  It works recursively starting at *node*.
    cs�d|jkr6t|d�s*||_q6|j}nd|jkrlt|d�s`||_ql|j}nx$t|�D]}�|||�qyWdS(Nulinenou
col_offset(u_attributesuhasattrulinenou
col_offsetuiter_child_nodes(unodeulinenou
col_offsetuchild(u_fix(u(/opt/alt/python33/lib64/python3.3/ast.pyu_fix�su#fix_missing_locations.<locals>._fixii((unode((u_fixu(/opt/alt/python33/lib64/python3.3/ast.pyufix_missing_locations�s
ufix_missing_locationsicCsFx?t|�D]1}d|jkr
t|dd�||_q
q
W|S(u�
    Increment the line number of each node in the tree starting at *node* by *n*.
    This is useful to "move code" to a different location in a file.
    ulinenoi(uwalku_attributesugetattrulineno(unodeunuchild((u(/opt/alt/python33/lib64/python3.3/ast.pyuincrement_lineno�s uincrement_linenoccsEx>|jD]3}y|t||�fVWq
tk
r<Yq
Xq
WdS(us
    Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
    that is present on *node*.
    N(u_fieldsugetattruAttributeError(unodeufield((u(/opt/alt/python33/lib64/python3.3/ast.pyuiter_fields�s

uiter_fieldsccsrxkt|�D]]\}}t|t�r0|Vq
t|t�r
x(|D]}t|t�rF|VqFqFWq
q
WdS(u�
    Yield all direct child nodes of *node*, that is, all fields that are nodes
    and all items of fields that are lists of nodes.
    N(uiter_fieldsu
isinstanceuASTulist(unodeunameufielduitem((u(/opt/alt/python33/lib64/python3.3/ast.pyuiter_child_nodes�s
uiter_child_nodescCs�t|tttf�s1td|jj��n|jr�t|jdt�r�t|jdj	t
�r�|r�ddl}|j|jdj	j
�S|jdj	j
SdS(u�
    Return the docstring for the given node or None if no docstring can
    be found.  If the node provided does not have docstrings a TypeError
    will be raised.
    u%r can't have docstringsiN(u
isinstanceuFunctionDefuClassDefuModuleu	TypeErroru	__class__u__name__ubodyuExpruvalueuStruinspectucleandocus(unodeucleanuinspect((u(/opt/alt/python33/lib64/python3.3/ast.pyu
get_docstring�su
get_docstringccsTddlm}||g�}x.|rO|j�}|jt|��|Vq"WdS(u�
    Recursively yield all descendant nodes in the tree starting at *node*
    (including *node* itself), in no specified order.  This is useful if you
    only want to modify nodes in place and don't care about the context.
    i(udequeN(ucollectionsudequeupopleftuextenduiter_child_nodes(unodeudequeutodo((u(/opt/alt/python33/lib64/python3.3/ast.pyuwalk�s	uwalkcBs2|EeZdZdZdd�Zdd�ZdS(uNodeVisitoru<
    A node visitor base class that walks the abstract syntax tree and calls a
    visitor function for every node found.  This function may return a value
    which is forwarded by the `visit` method.

    This class is meant to be subclassed, with the subclass adding visitor
    methods.

    Per default the visitor functions for the nodes are ``'visit_'`` +
    class name of the node.  So a `TryFinally` node visit function would
    be `visit_TryFinally`.  This behavior can be changed by overriding
    the `visit` method.  If no visitor function exists for a node
    (return value `None`) the `generic_visit` visitor is used instead.

    Don't use the `NodeVisitor` if you want to apply changes to nodes during
    traversing.  For this a special visitor exists (`NodeTransformer`) that
    allows modifications.
    cCs/d|jj}t|||j�}||�S(u
Visit a node.uvisit_(u	__class__u__name__ugetattru
generic_visit(uselfunodeumethoduvisitor((u(/opt/alt/python33/lib64/python3.3/ast.pyuvisit�suNodeVisitor.visitcCs�x{t|�D]m\}}t|t�r[xO|D]%}t|t�r/|j|�q/q/Wq
t|t�r
|j|�q
q
WdS(u9Called if no explicit visitor function exists for a node.N(uiter_fieldsu
isinstanceulistuASTuvisit(uselfunodeufielduvalueuitem((u(/opt/alt/python33/lib64/python3.3/ast.pyu
generic_visit�s
uNodeVisitor.generic_visitN(u__name__u
__module__u__qualname__u__doc__uvisitu
generic_visit(u
__locals__((u(/opt/alt/python33/lib64/python3.3/ast.pyuNodeVisitor�suNodeVisitorcBs&|EeZdZdZdd�ZdS(uNodeTransformeru\
    A :class:`NodeVisitor` subclass that walks the abstract syntax tree and
    allows modification of nodes.

    The `NodeTransformer` will walk the AST and use the return value of the
    visitor methods to replace or remove the old node.  If the return value of
    the visitor method is ``None``, the node will be removed from its location,
    otherwise it is replaced with the return value.  The return value may be the
    original node in which case no replacement takes place.

    Here is an example transformer that rewrites all occurrences of name lookups
    (``foo``) to ``data['foo']``::

       class RewriteName(NodeTransformer):

           def visit_Name(self, node):
               return copy_location(Subscript(
                   value=Name(id='data', ctx=Load()),
                   slice=Index(value=Str(s=node.id)),
                   ctx=node.ctx
               ), node)

    Keep in mind that if the node you're operating on has child nodes you must
    either transform the child nodes yourself or call the :meth:`generic_visit`
    method for the node first.

    For nodes that were part of a collection of statements (that applies to all
    statement nodes), the visitor may also return a list of nodes rather than
    just a single node.

    Usually you use the transformer like this::

       node = YourTransformer().visit(node)
    cCsxt|�D]\}}t||d�}t|t�r�g}xp|D]h}t|t�r�|j|�}|dkr}qGq�t|t�s�|j|�qGq�n|j|�qGW||dd�<q
t|t�r
|j|�}|dkrt	||�qt
|||�q
q
W|S(N(uiter_fieldsugetattruNoneu
isinstanceulistuASTuvisituextenduappendudelattrusetattr(uselfunodeufieldu	old_valueu
new_valuesuvalueunew_node((u(/opt/alt/python33/lib64/python3.3/ast.pyu
generic_visit(s(

	uNodeTransformer.generic_visitN(u__name__u
__module__u__qualname__u__doc__u
generic_visit(u
__locals__((u(/opt/alt/python33/lib64/python3.3/ast.pyuNodeTransformers"uNodeTransformerNTF(u__doc__u_astuparseuliteral_evaluTrueuFalseudumpu
copy_locationufix_missing_locationsuincrement_linenouiter_fieldsuiter_child_nodesu
get_docstringuwalkuobjectuNodeVisitoruNodeTransformer(((u(/opt/alt/python33/lib64/python3.3/ast.pyu<module>s
3%

Hacked By AnonymousFox1.0, Coded By AnonymousFox