mirror of https://github.com/mitsuhiko/flask.git
Browse Source
Moved away from using manual parsing. Source is parsed using RedBaron to make the FST. Some import formats not yet implemented, and still some bugs to work out. However, the current script works well for the two cases in the file comments.pull/1342/head
Keyan Pishdadian
10 years ago
3 changed files with 51 additions and 27 deletions
@ -1,20 +0,0 @@ |
|||||||
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…
Reference in new issue