b374k
m1n1 1.01
Apache/2.2.15 (CentOS)
Linux obd60-6c49958d75-2q7cw 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
uid=48(apache) gid=48(apache) groups=48(apache)
server ip : 104.21.65.202 | your ip : 10.244.126.0
safemode OFF
 >  / usr / lib64 / python2.6 /
Filename/usr/lib64/python2.6/ast.pyo
Size12.48 kb
Permissionrw-r--r--
Ownerapache
Create time23-Dec-2025 17:41
Last modified20-Jun-2019 19:45
Last accessed22-Apr-2026 05:24
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
Ñò
§ÚêLc@s¼dZddkTddklZddd�Zd�Zeed�Zd �Zd
�Z d d �Z
d
�Z d�Z ed�Z
d�Zdefd��YZdefd��YZdS(sH
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ÿÿÿÿ(t*(t __version__s <unknown>texeccCst|||t�S(so
Parse an expression into an AST node.
Equivalent to compile(expr, filename, mode, PyCF_ONLY_AST).
(tcompilet
PyCF_ONLY_AST(texprtfilenametmode((s/usr/lib64/python2.6/ast.pytparse scszhdd6td6td6�t|t�ot|dd�}nt|t�o
|i}n��fd���|�S(sú
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, numbers, tuples, lists, dicts, booleans,
and None.
tNonetTruetFalseRtevalcsøt|t�o|iSt|t�o|iSt|t�ott�|i��St|t �ot
t�|i��St|t �o*t �fd�t
|i|i�D��St|t�o |i�jo �|iSntd��dS(Nc3s1x*|]#\}}�|��|�fVqWdS(N((t.0tktv(t_convert(s/usr/lib64/python2.6/ast.pys <genexpr>>s smalformed string(t
isinstancetStrtstNumtntTuplettupletmapteltstListtlisttDicttdicttziptkeystvaluestNametidt
ValueError(tnode(t _safe_namesR(s/usr/lib64/python2.6/ast.pyR4sN(R R
R Rt
basestringRt
Expressiontbody(tnode_or_string((R%Rs/usr/lib64/python2.6/ast.pyt literal_eval(s
csI���fd��t|t�ptd|ii��n�|�S(s»
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�oÙg}t��D]\}}||�|�fq!~}d�iidi�od�|D�nd�|D��f}�oO�ioE||odpd7}|di��fd��iD��7}n|dSt�t�o"ddi�fd ��D��St��S(
Ns%s(%ss, cssx|]}d|VqWdS(s%s=%sN((R
tfield((s/usr/lib64/python2.6/ast.pys <genexpr>Ts cssx|]\}}|VqWdS(N((R
tatb((s/usr/lib64/python2.6/ast.pys <genexpr>Vs t c3s2x+|]$}d|�t�|��fVqWdS(s%s=%sN(tgetattr(R
R,(R$t_format(s/usr/lib64/python2.6/ast.pys <genexpr>Zs t)s[%s]c3sx|]}�|�VqWdS(N((R
tx(R0(s/usr/lib64/python2.6/ast.pys <genexpr>^s ( RtASTt iter_fieldst __class__t__name__tjoint _attributesRtrepr(R$t_[1]R,R-tfieldstrv(tinclude_attributestannotate_fieldsR0(R$s/usr/lib64/python2.6/ast.pyR0Ps9 "sexpected AST, got %r(RR3t TypeErrorR5R6(R$R>R=((R0R=R>s/usr/lib64/python2.6/ast.pytdumpGs cCsbx[dD]S}||ijo=||ijo-t||�ot||t||��qqW|S(s�
Copy source location (`lineno` and `col_offset` attributes) from
*old_node* to *new_node* if possible, and return *new_node*.
tlinenot
col_offset(slinenos
col_offset(R8thasattrtsetattrR/(tnew_nodetold_nodetattr((s/usr/lib64/python2.6/ast.pyt
copy_locationes  !cs#�fd���|dd�|S(s{
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|ijo*t|d�p
||_q:|i}nd|ijo*t|d�p
||_qt|i}nx$t|�D]}�|||�q�WdS(NRARB(R8RCRARBtiter_child_nodes(R$RARBtchild(t_fix(s/usr/lib64/python2.6/ast.pyRKys




ii((R$((RKs/usr/lib64/python2.6/ast.pytfix_missing_locationsqs
icCsud|ijot|dd�||_nxAt|�D]3}d|ijot|dd�||_q:q:W|S(s�
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.
RAi(R8R/RAtwalk(R$RRJ((s/usr/lib64/python2.6/ast.pytincrement_lineno�s
!ccsFx?|iD]4}y|t||�fVWq
tj
oq
Xq
WdS(ss
Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
that is present on *node*.
N(t_fieldsR/tAttributeError(R$R+((s/usr/lib64/python2.6/ast.pyR4�s 
ccsxxqt|�D]c\}}t|t�o |Vq
t|t�o.x+|D]}t|t�o |VqIqIWq
q
WdS(s�
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(R4RR3R(R$tnameR+titem((s/usr/lib64/python2.6/ast.pyRI£s
 cCs²t|tttf�ptd|ii��n|ioqt|idt�oZt|idi t
�o@|o'ddk }|i |idi i
�S|idi i
SdS(sª
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.
s%r can't have docstringsiiÿÿÿÿN(Rt FunctionDeftClassDeftModuleR?R5R6R(tExprtvalueRtinspecttcleandocR(R$tcleanRX((s/usr/lib64/python2.6/ast.pyt
get_docstring±s! ccsVddkl}||g�}x0|o(|i�}|it|��|Vq"WdS(s±
Recursively yield all child nodes of *node*, in no specified order. This is
useful if you only want to modify nodes in place and don't care about the
context.
iÿÿÿÿ(tdequeN(t collectionsR\tpoplefttextendRI(R$R\ttodo((s/usr/lib64/python2.6/ast.pyRMÁs t NodeVisitorcBs eZdZd�Zd�ZRS(s<
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|ii}t|||i�}||�S(s
Visit a node.tvisit_(R5R6R/t
generic_visit(tselfR$tmethodtvisitor((s/usr/lib64/python2.6/ast.pytvisitãscCs�x�t|�D]s\}}t|t�o6xT|D]'}t|t�o|i|�q0q0Wq
t|t�o|i|�q
q
WdS(s9Called if no explicit visitor function exists for a node.N(R4RRR3Rg(RdR$R+RWRR((s/usr/lib64/python2.6/ast.pyRcés
(R6t
__module__t__doc__RgRc(((s/usr/lib64/python2.6/ast.pyRaÏs tNodeTransformercBseZdZd�ZRS(s\
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�o�g}xv|D]n}t|t�oK|i|�}|djoqHq©t|t�p|i|�qHq©n|i|�qHW||(q
t|t�oA|i|�}|djot ||�qt
|||�q
q
W|S(N( R4R/R RRR3RgR_tappendtdelattrRD(RdR$R+t old_valuet
new_valuesRWRE((s/usr/lib64/python2.6/ast.pyRcs,


  
(R6RhRiRc(((s/usr/lib64/python2.6/ast.pyRjôs"N(Rit_astRRR*R
R R@RHRLRNR4RIR[RMtobjectRaRj(((s/usr/lib64/python2.6/ast.pyt<module>s
  
  %