Show More
@@ -567,6 +567,11 b' def find_cycles(imports):' | |||
|
567 | 567 | def _cycle_sortkey(c): |
|
568 | 568 | return len(c), c |
|
569 | 569 | |
|
570 | def sources(f, modname): | |
|
571 | if f.endswith('.py'): | |
|
572 | with open(f) as src: | |
|
573 | yield src.read(), modname | |
|
574 | ||
|
570 | 575 | def main(argv): |
|
571 | 576 | if len(argv) < 2 or (argv[1] == '-' and len(argv) > 2): |
|
572 | 577 | print('Usage: %s {-|file [file] [file] ...}') |
@@ -580,15 +585,14 b' def main(argv):' | |||
|
580 | 585 | for source_path in argv[1:]: |
|
581 | 586 | modname = dotted_name_of_path(source_path, trimpure=True) |
|
582 | 587 | localmods[modname] = source_path |
|
583 | for modname, source_path in sorted(localmods.items()): | |
|
584 | f = open(source_path) | |
|
585 | src = f.read() | |
|
586 | used_imports[modname] = sorted( | |
|
587 | imported_modules(src, modname, localmods, ignore_nested=True)) | |
|
588 | for error, lineno in verify_import_convention(modname, src, localmods): | |
|
589 | any_errors = True | |
|
590 | print('%s:%d: %s' % (source_path, lineno, error)) | |
|
591 | f.close() | |
|
588 | for localmodname, source_path in sorted(localmods.items()): | |
|
589 | for src, modname in sources(source_path, localmodname): | |
|
590 | used_imports[modname] = sorted( | |
|
591 | imported_modules(src, modname, localmods, ignore_nested=True)) | |
|
592 | for error, lineno in verify_import_convention(modname, src, | |
|
593 | localmods): | |
|
594 | any_errors = True | |
|
595 | print('%s:%d: %s' % (source_path, lineno, error)) | |
|
592 | 596 | cycles = find_cycles(used_imports) |
|
593 | 597 | if cycles: |
|
594 | 598 | firstmods = set() |
General Comments 0
You need to be logged in to leave comments.
Login now