diff options
author | Eli Bendersky <eliben@gmail.com> | 2013-05-25 07:12:38 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2013-05-25 07:12:38 -0700 |
commit | c5859d4e0f25c140ab7585218e582ece2a3b678f (patch) | |
tree | f6361263c47d9a73ca0aba186891efd4bad7585d /Lib/lib2to3/fixes/fix_reload.py | |
parent | 9dc3e38c16914e88419d325867c17e23f9c6ed8f (diff) | |
parent | 43571906e334ddae42f9cbda3c1e6a3f8dd864be (diff) | |
download | cpython-c5859d4e0f25c140ab7585218e582ece2a3b678f.tar.gz |
Clean-up duplicated code in tests
Diffstat (limited to 'Lib/lib2to3/fixes/fix_reload.py')
-rw-r--r-- | Lib/lib2to3/fixes/fix_reload.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/lib2to3/fixes/fix_reload.py b/Lib/lib2to3/fixes/fix_reload.py new file mode 100644 index 0000000000..1855357588 --- /dev/null +++ b/Lib/lib2to3/fixes/fix_reload.py @@ -0,0 +1,28 @@ +"""Fixer for reload(). + +reload(s) -> imp.reload(s)""" + +# Local imports +from .. import fixer_base +from ..fixer_util import ImportAndCall, touch_import + + +class FixReload(fixer_base.BaseFix): + BM_compatible = True + order = "pre" + + PATTERN = """ + power< 'reload' + trailer< lpar='(' + ( not(arglist | argument<any '=' any>) obj=any + | obj=arglist<(not argument<any '=' any>) any ','> ) + rpar=')' > + after=any* + > + """ + + def transform(self, node, results): + names = ('imp', 'reload') + new = ImportAndCall(node, results, names) + touch_import(None, 'imp', node) + return new |