|
|
|
@ -33,6 +33,9 @@ except ImportError:
|
|
|
|
|
ast = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEMPLATE_LOOKAHEAD = 4096 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_from_import_re = re.compile(r'^\s*from flask import\s+') |
|
|
|
|
_string_re_part = r"('([^'\\]*(?:\\.[^'\\]*)*)'" \ |
|
|
|
|
r'|"([^"\\]*(?:\\.[^"\\]*)*)")' |
|
|
|
@ -50,11 +53,6 @@ _blueprint_related = [
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def error(message): |
|
|
|
|
print >> sys.stderr, 'error:', message |
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_diff(filename, old, new): |
|
|
|
|
for line in difflib.unified_diff(old.splitlines(), new.splitlines(), |
|
|
|
|
posixpath.normpath(posixpath.join('a', filename)), |
|
|
|
@ -253,7 +251,7 @@ def walk_path(path):
|
|
|
|
|
yield filename, 'python' |
|
|
|
|
else: |
|
|
|
|
with open(filename) as f: |
|
|
|
|
contents = f.read() |
|
|
|
|
contents = f.read(TEMPLATE_LOOKAHEAD) |
|
|
|
|
if '{% for' or '{% if' or '{{ url_for' in contents: |
|
|
|
|
yield filename, 'template' |
|
|
|
|
|
|
|
|
@ -286,11 +284,6 @@ def autodetect_template_bundles(paths):
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
"""Entrypoint""" |
|
|
|
|
if ast is None: |
|
|
|
|
error('Python 2.6 or later is required to run the upgrade script.\n' |
|
|
|
|
'The runtime requirements for Flask 0.7 however are still ' |
|
|
|
|
'Python 2.5.') |
|
|
|
|
|
|
|
|
|
parser = OptionParser() |
|
|
|
|
parser.add_option('-T', '--no-teardown-detection', dest='no_teardown', |
|
|
|
|
action='store_true', help='Do not attempt to ' |
|
|
|
@ -307,6 +300,11 @@ def main():
|
|
|
|
|
if not args: |
|
|
|
|
args = ['.'] |
|
|
|
|
|
|
|
|
|
if ast is None: |
|
|
|
|
parser.error('Python 2.6 or later is required to run the upgrade script.\n' |
|
|
|
|
'The runtime requirements for Flask 0.7 however are still ' |
|
|
|
|
'Python 2.5.') |
|
|
|
|
|
|
|
|
|
if options.no_bundled_tmpl: |
|
|
|
|
template_bundles = False |
|
|
|
|
elif options.bundled_tmpl: |
|
|
|
|