contrib/import-checker.py
changeset 25064 3bbbadf69d0a
parent 25063 723e364488f4
child 25173 7358b5d9991e
equal deleted inserted replaced
25063:723e364488f4 25064:3bbbadf69d0a
   219         print 'Usage: %s {-|file [file] [file] ...}'
   219         print 'Usage: %s {-|file [file] [file] ...}'
   220         return 1
   220         return 1
   221     if argv[1] == '-':
   221     if argv[1] == '-':
   222         argv = argv[:1]
   222         argv = argv[:1]
   223         argv.extend(l.rstrip() for l in sys.stdin.readlines())
   223         argv.extend(l.rstrip() for l in sys.stdin.readlines())
       
   224     localmods = {}
   224     used_imports = {}
   225     used_imports = {}
   225     any_errors = False
   226     any_errors = False
   226     for source_path in argv[1:]:
   227     for source_path in argv[1:]:
       
   228         modname = dotted_name_of_path(source_path, trimpure=True)
       
   229         localmods[modname] = source_path
       
   230     for modname, source_path in sorted(localmods.iteritems()):
   227         f = open(source_path)
   231         f = open(source_path)
   228         modname = dotted_name_of_path(source_path, trimpure=True)
       
   229         src = f.read()
   232         src = f.read()
   230         used_imports[modname] = sorted(
   233         used_imports[modname] = sorted(
   231             imported_modules(src, ignore_nested=True))
   234             imported_modules(src, ignore_nested=True))
   232         for error in verify_stdlib_on_own_line(src):
   235         for error in verify_stdlib_on_own_line(src):
   233             any_errors = True
   236             any_errors = True