forked from orbit-oss/flask
Add lib2to3 fixer base code
Switching to using RedBaron instead of lib2to3, committing to save lib2to3 code in case using Baron is not successful.
This commit is contained in:
parent
9d64ff420f
commit
0b2556f3ec
4 changed files with 28 additions and 43 deletions
20
scripts/fix_ext_import.py
Normal file
20
scripts/fix_ext_import.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from lib2to3.fixer_base import BaseFix
|
||||
from lib2to3.fixer_util import Name, syms
|
||||
|
||||
|
||||
class FixExtImport(BaseFix):
|
||||
|
||||
PATTERN = "fixnode='oldname'"
|
||||
|
||||
def transform(self, node, results):
|
||||
fixnode = results['fixnode']
|
||||
fixnode.replace(Name('newname', prefix=fixnode.prefix))
|
||||
|
||||
if node.type == syms.import_from and \
|
||||
getattr(results['imp'], 'value', None) == 'flask.ext':
|
||||
return 0
|
||||
# TODO: Case 2
|
||||
|
||||
|
||||
# CASE 1 - from flask.ext.foo import bam --> from flask_foo import bam
|
||||
# CASE 2 - from flask.ext import foo --> import flask_foo as foo
|
||||
Loading…
Add table
Add a link
Reference in a new issue