ACC SHELL
Ñò
sÄMc @ s~ d Z d d k Z d d k Z d d k l Z d d k l Z d d k l Z d e f d „ ƒ YZ
d e
f d
„ ƒ YZ d S( s2 Base class for fixers (optional, but recommended).iÿÿÿÿNi ( t PatternCompiler( t pygram( t does_tree_importt BaseFixc B sÎ e Z d Z d Z d Z d Z d Z d Z e i
d ƒ Z e ƒ Z
d Z e Z d Z d Z e i Z d „ Z d „ Z d „ Z d „ Z d „ Z d d
„ Z d „ Z d d „ Z d
„ Z d „ Z d „ Z RS( s Optional base class for fixers.
The subclass name must be FixFooBar where FooBar is the result of
removing underscores and capitalizing the words of the fix name.
For example, the class name for a fixer named 'has_key' should be
FixHasKey.
i t posti c C s | | _ | | _ | i ƒ d S( s Initializer. Subclass may override.
Args:
options: an dict containing the options passed to RefactoringTool
that could be used to customize the fixer through the command line.
log: a list to append warnings and other messages to.
N( t optionst logt compile_pattern( t selfR R ( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt __init__* s c C s0 | i d j o t ƒ i | i ƒ | _ n d S( s– Compiles self.PATTERN into self.pattern.
Subclass may override if it doesn't want to use
self.{pattern,PATTERN} in .match().
N( t PATTERNt NoneR R t pattern( R ( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyR 6 s c C s | | _ t i | ƒ | _ d S( sm Set the filename, and a logger derived from it.
The main refactoring tool should call this.
N( t filenamet loggingt getLoggert logger( R R
( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt set_filename? s c C s' h | d 6} | i i | | ƒ o | S( s Returns match for a given parse tree node.
Should return a true or false object (not necessarily a bool).
It may return a non-empty dict of matching sub-nodes as
returned by a matching pattern.
Subclass may override.
t node( R t match( R R t results( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyR G s
c C s
t ƒ ‚ d S( s¶ Returns the transformation for a given parse tree node.
Args:
node: the root of the parse tree that matched the fixer.
results: a dict mapping symbolic names to part of the match.
Returns:
None, or a node that is a modified copy of the
argument node. The node argument may also be modified in-place to
effect the same change.
Subclass *must* override.
N( t NotImplementedError( R R R ( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt transformS s u xxx_todo_changemec C sK | } x. | | i j o | t | i i ƒ ƒ } q W| i i | ƒ | S( s† Return a string suitable for use as an identifier
The new name is guaranteed not to conflict with other identifiers.
( t
used_namest unicodet numberst nextt add( R t templatet name( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt new_namec s c C sB | i o$ t | _ | i i d | i ƒ n | i i | ƒ d S( Ns ### In file %s ###( t first_logt FalseR t appendR
( R t message( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt log_messagen s
c C sZ | i ƒ } | i ƒ } d | _ d } | i | | | f ƒ | o | i | ƒ n d S( s Warn the user that a given chunk of code is not valid Python 3,
but that it cannot be converted automatically.
First argument is the top-level node for the code in question.
Optional second argument is why it can't be converted.
u s Line %d: could not convert: %sN( t
get_linenot clonet prefixR# ( R R t reasont linenot
for_outputt msg( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt cannot_convertt s c C s' | i ƒ } | i d | | f ƒ d S( sà Used for warning the user about possible uncertainty in the
translation.
First argument is the top-level node for the code in question.
Optional second argument is why it can't be converted.
s Line %d: %sN( R$ R# ( R R R' R( ( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt warningƒ s c C s8 | i | _ | i | ƒ t i d ƒ | _ t | _ d S( sî Some fixers need to maintain tree-wide state.
This method is called once, at the start of tree fix-up.
tree - the root node of the tree to be processed.
filename - the name of the file the tree came from.
i N( R R t itertoolst countR t TrueR ( R t treeR
( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt
start_tree s
c C s d S( só Some fixers need to maintain tree-wide state.
This method is called once, at the conclusion of tree fix-up.
tree - the root node of the tree to be processed.
filename - the name of the file the tree came from.
N( ( R R0 R
( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyt finish_tree™ s N(! t __name__t
__module__t __doc__R R
R R R
R R- R. R t setR t orderR t explicitt run_ordert _accept_typeR t python_symbolst symsR R R R R R R# R+ R, R1 R2 ( ( ( s( /usr/lib/python2.6/lib2to3/fixer_base.pyR s0
t ConditionalFixc B s&