Back to index

python3.2  3.2.2
Classes | Functions | Variables
lib2to3.fixes.fix_imports Namespace Reference

Classes

class  FixImports

Functions

def alternates
def build_pattern

Variables

dictionary MAPPING

Detailed Description

Fix incompatible imports and module references.

Function Documentation

Definition at line 61 of file fix_imports.py.

00061 
00062 def alternates(members):
00063     return "(" + "|".join(map(repr, members)) + ")"
00064 

Here is the caller graph for this function:

def lib2to3.fixes.fix_imports.build_pattern (   mapping = MAPPING)

Definition at line 65 of file fix_imports.py.

00065 
00066 def build_pattern(mapping=MAPPING):
00067     mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
00068     bare_names = alternates(mapping.keys())
00069 
00070     yield """name_import=import_name< 'import' ((%s) |
00071                multiple_imports=dotted_as_names< any* (%s) any* >) >
00072           """ % (mod_list, mod_list)
00073     yield """import_from< 'from' (%s) 'import' ['(']
00074               ( any | import_as_name< any 'as' any > |
00075                 import_as_names< any* >)  [')'] >
00076           """ % mod_list
00077     yield """import_name< 'import' (dotted_as_name< (%s) 'as' any > |
00078                multiple_imports=dotted_as_names<
00079                  any* dotted_as_name< (%s) 'as' any > any* >) >
00080           """ % (mod_list, mod_list)
00081 
00082     # Find usages of module members in code e.g. thread.foo(bar)
00083     yield "power< bare_with_attr=(%s) trailer<'.' any > any* >" % bare_names
00084 

Here is the call graph for this function:


Variable Documentation

Definition at line 8 of file fix_imports.py.