comparison contrib/import-checker.py @ 25064:3bbbadf69d0a

import-checker: loop to get list of locally defined modules at first This is a preparation for subsequent patches, which expect that all locally defined (= mercurial specific) modules are already known before examinations. Looping twice for specified modules is a little redundant, but reasonable cost for improvement in subsequent patches.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 14 May 2015 01:49:10 +0900
parents 723e364488f4
children 7358b5d9991e
comparison
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