Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \†/ã@s’dZddlTd!dd„ZeeefZdd„Zd"d d „Zd d„Z dd„Z d#dd„Z dd„Z dd„Z d$dd„Zdd„ZGdd„deƒZGdd„deƒZd S)%aH 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. é)Ú*ú ÚexeccCst|||tƒS)zn Parse the source into an AST node. Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). )ÚcompileZ PyCF_ONLY_AST)ÚsourceÚfilenameÚmode©r ú/usr/lib64/python3.6/ast.pyÚparsesr cs:t|tƒrt|dd�}t|tƒr&|j}‡fdd„‰ˆ|ƒS)a 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. Úeval)rcs†t|tƒr|jSt|ttfƒr$|jSt|tƒr4|jSt|tƒrNt t ˆ|j ƒƒSt|t ƒrht t ˆ|j ƒƒSt|tƒr‚tt ˆ|j ƒƒSt|tƒr¬t‡fdd„t|j|jƒDƒƒSt|tƒr¼|jSt|tƒoÔt|jttfƒ�r ˆ|jƒ}t|tƒ�rrt|jtƒ�r| S| Snht|tƒ�rrt|jttfƒ�rrˆ|jƒ}ˆ|j ƒ}t|tƒ�rrt|tƒ�rrt|jtƒ�rj||S||St!dt"|ƒƒ‚dS)Nc3s"|]\}}ˆ|ƒˆ|ƒfVqdS)Nr )Ú.0ÚkÚv)Ú_convertr r ú Asz1literal_eval.._convert..zmalformed node or string: )#Ú isinstanceÚConstantÚvalueÚStrZBytesÚsZNumÚnZTupleÚtupleÚmapZeltsZListÚlistÚSetÚsetZDictÚdictÚzipÚkeysÚvaluesZ NameConstantZUnaryOpÚopZUAddZUSubÚoperandÚ _NUM_TYPESZBinOpZAddZSubÚleftÚrightÚ ValueErrorÚrepr)Únoder"r$r%)rr r r3s>            zliteral_eval.._convert)rÚstrr Z ExpressionÚbody)Znode_or_stringr )rr Ú literal_eval(s     "r+TFcs2‡‡‡fdd„‰t|tƒs*td|jjƒ‚ˆ|ƒS)a» 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ˆr>dd„|Dƒn dd„|Dƒƒf}ˆrŒˆjrŒ||rfdphd7}|dj‡‡fd d„ˆjDƒƒ7}|d Stˆtƒrºd dj‡fd d„ˆDƒƒStˆƒS) Ncsg|]\}}|ˆ|ƒf‘qSr r )r ÚaÚb)Ú_formatr r ú csz)dump.._format..z%s(%sz, css|]}d|VqdS)z%s=%sNr )r Úfieldr r r resz(dump.._format..css|]\}}|VqdS)Nr )r r,r-r r r rgsú c3s$|]}d|ˆtˆ|ƒƒfVqdS)z%s=%sN)Úgetattr)r r,)r.r(r r rksú)z[%s]c3s|]}ˆ|ƒVqdS)Nr )r Úx)r.r r ros) rÚASTÚ iter_fieldsÚ __class__Ú__name__ÚjoinÚ _attributesrr')r(ZfieldsÚrv)r.Úannotate_fieldsÚinclude_attributes)r(r r.as    zdump.._formatzexpected AST, got %r)rr5Ú TypeErrorr7r8)r(r<r=r )r.r<r=r ÚdumpXs  r?cCsBx||_n|j}xt|ƒD]}ˆ|||ƒqNWdS)Nr@rA)r:rBr@rAÚiter_child_nodes)r(r@rAÚchild)Ú_fixr r rIŠs    z#fix_missing_locations.._fixérr )r(r )rIr Úfix_missing_locations‚s rKrJcCs2x,t|ƒD] }d|jkr t|ddƒ||_q W|S)zœ 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. r@r)Úwalkr:r2r@)r(rrHr r r Úincrement_lineno›s rMc cs>x8|jD].}y|t||ƒfVWqtk r4YqXqWdS)zs Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` that is present on *node*. N)Ú_fieldsr2ÚAttributeError)r(r0r r r r6¦s  r6ccsTxNt|ƒD]B\}}t|tƒr$|Vq t|tƒr x|D]}t|tƒr4|Vq4Wq WdS)z‰ 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)r6rr5r)r(Únamer0Úitemr r r rG²s    rGcCs–t|ttttfƒs"td|jjƒ‚|jo6t|jdt ƒsr7r8r*ZExprrrrrr)ÚinspectZcleandoc)r(ZcleanÚtextrRr r r Ú get_docstringÀs   rTccs@ddlm}||gƒ}x$|r:|jƒ}|jt|ƒƒ|VqWdS)zå 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. r)ÚdequeN)Ú collectionsrUÚpopleftÚextendrG)r(rUZtodor r r rL×s   rLc@s eZdZdZdd„Zdd„ZdS)Ú NodeVisitora< 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)z Visit a node.Zvisit_)r7r8r2Ú generic_visit)Úselfr(ÚmethodZvisitorr r r Úvisitùs zNodeVisitor.visitcCs\xVt|ƒD]J\}}t|tƒr@x6|D]}t|tƒr"|j|ƒq"Wq t|tƒr |j|ƒq WdS)z9Called if no explicit visitor function exists for a node.N)r6rrr5r])r[r(r0rrQr r r rZÿs    zNodeVisitor.generic_visitN)r8Ú __module__Ú __qualname__Ú__doc__r]rZr r r r rYåsrYc@seZdZdZdd„ZdS)ÚNodeTransformera\ 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) cCs¸x²t|ƒD]¦\}}t|tƒr|g}xL|D]D}t|tƒr`|j|ƒ}|dkrJq&nt|tƒs`|j|ƒq&|j|ƒq&W||dd…<q t|tƒr |j|ƒ}|dkr¤t||ƒq t|||ƒq W|S)N) r6rrr5r]rXÚappendÚdelattrrC)r[r(r0Z old_valueZ new_valuesrrDr r r rZ.s&         zNodeTransformer.generic_visitN)r8r^r_r`rZr r r r ra s"raN)rr)TF)rJ)T)r`Z_astr ÚintÚfloatÚcomplexr#r+r?rFrKrMr6rGrTrLÚobjectrYrar r r r Ús  0     %