flask/scripts/test.py
Keyan Pishdadian 8488a3afa9 Change parsing format to use AST via RedBaron
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.
2015-02-11 13:07:24 -05:00

33 lines
731 B
Python

from flask.ext.foo import \
bam, \
crackle
from flask.ext import foo
from flask.ext.foo import (bam,
a,
b
)
from flask.ext import foo
import sys
def migrate(old_file):
new_file = open("temp.py", "w")
for line in old_file:
if line[0, 15] is "from flask.ext":
if line[15] == '.':
import_statement = line[16::].split(' ')
extension = import_statement[0]
line = line. replace("flask.ext." + extension,
"flask_" + extension)
else:
pass
new_file.write(line)
if __name__ == "__main__":
old_file = open(sys.arv[1])