contrib/import-checker.py
changeset 32542 a025ec43856c
parent 32541 4c712b90c60a
child 32621 9e46627baa3c
equal deleted inserted replaced
32541:4c712b90c60a 32542:a025ec43856c
   167             dottedpath = n + '.__init__'
   167             dottedpath = n + '.__init__'
   168             if dottedpath in localmods:
   168             if dottedpath in localmods:
   169                 return (n, dottedpath, True)
   169                 return (n, dottedpath, True)
   170         return False
   170         return False
   171     return fromlocal
   171     return fromlocal
       
   172 
       
   173 def populateextmods(localmods):
       
   174     """Populate C extension modules based on pure modules"""
       
   175     newlocalmods = set(localmods)
       
   176     for n in localmods:
       
   177         if n.startswith('mercurial.pure.'):
       
   178             m = n[len('mercurial.pure.'):]
       
   179             newlocalmods.add('mercurial.cext.' + m)
       
   180             newlocalmods.add('mercurial.cffi._' + m)
       
   181     return newlocalmods
   172 
   182 
   173 def list_stdlib_modules():
   183 def list_stdlib_modules():
   174     """List the modules present in the stdlib.
   184     """List the modules present in the stdlib.
   175 
   185 
   176     >>> mods = set(list_stdlib_modules())
   186     >>> mods = set(list_stdlib_modules())
   699     used_imports = {}
   709     used_imports = {}
   700     any_errors = False
   710     any_errors = False
   701     for source_path in argv[1:]:
   711     for source_path in argv[1:]:
   702         modname = dotted_name_of_path(source_path)
   712         modname = dotted_name_of_path(source_path)
   703         localmodpaths[modname] = source_path
   713         localmodpaths[modname] = source_path
   704     localmods = set(localmodpaths)
   714     localmods = populateextmods(localmodpaths)
   705     for localmodname, source_path in sorted(localmodpaths.items()):
   715     for localmodname, source_path in sorted(localmodpaths.items()):
   706         for src, modname, name, line in sources(source_path, localmodname):
   716         for src, modname, name, line in sources(source_path, localmodname):
   707             try:
   717             try:
   708                 used_imports[modname] = sorted(
   718                 used_imports[modname] = sorted(
   709                     imported_modules(src, modname, name, localmods,
   719                     imported_modules(src, modname, name, localmods,