|
38 | 38 |
|
39 | 39 | exclude_dirs = ['state', 'user-projects', 'doc-src',
|
40 | 40 | 'MiG-certificates', 'seafile']
|
| 41 | +# The import fix breaks our relative imports so disable for now |
| 42 | +disable_import_fix = True |
41 | 43 |
|
42 | 44 | if __name__ == '__main__':
|
43 | 45 | if len(sys.argv) < 2:
|
|
53 | 55 | print('--- ignoring all %s dirs ---' % ', '.join(exclude_dirs))
|
54 | 56 | mime_helper = mimetypes.MimeTypes()
|
55 | 57 | modernize_base = ['python-modernize', '-n', '-w']
|
| 58 | + if disable_import_fix: |
| 59 | + modernize_base += ['-x', 'import'] |
56 | 60 | # NOTE: fix import lines broken by modernize and leave Copyright line alone
|
57 |
| - sed_rules = ['s/^from .shared/from shared/g', |
58 |
| - 's/^from . import /import /g'] |
| 61 | + sed_rules = ['s/from .shared/from shared/g', |
| 62 | + 's/from . import /import /g'] |
59 | 63 | postprocess_base = ['sed', '-i'] + [';'.join(sed_rules)]
|
60 | 64 | for (root, dirs, files) in os.walk(target):
|
61 | 65 | timestamp = time.time()
|
|
97 | 101 | if modernize_retval != 0:
|
98 | 102 | print("ERROR: failed to modernize %s" % rel_path)
|
99 | 103 | continue
|
| 104 | + # Nothing to fix if import fix is disabled |
| 105 | + if disable_import_fix: |
| 106 | + continue |
100 | 107 | # Skip postprocessing unless file actually changed
|
101 | 108 | if timestamp - os.path.getmtime(path) > 0:
|
102 | 109 | continue
|
|
0 commit comments