Utilities/ClassBrowsers/pyclbr.py

changeset 5651
982465f8389c
parent 5604
b047181a4a33
child 6048
82ad8ec9548c
equal deleted inserted replaced
5650:4c52f07c186e 5651:982465f8389c
323 self.importedNames[name] = [lineno] 323 self.importedNames[name] = [lineno]
324 else: 324 else:
325 self.importedNames[name].append(lineno) 325 self.importedNames[name].append(lineno)
326 326
327 327
328 def readmodule_ex(module, path=[], inpackage=False, isPyFile=False): 328 def readmodule_ex(module, path=None, inpackage=False, isPyFile=False):
329 """ 329 """
330 Read a module file and return a dictionary of classes. 330 Read a module file and return a dictionary of classes.
331 331
332 Search for MODULE in PATH and sys.path, read and parse the 332 Search for MODULE in PATH and sys.path, read and parse the
333 module and return a dictionary with one entry for each class 333 module and return a dictionary with one entry for each class
351 # this is a built-in module 351 # this is a built-in module
352 _modules[module] = dictionary 352 _modules[module] = dictionary
353 return dictionary 353 return dictionary
354 354
355 # search the path for the module 355 # search the path for the module
356 path = [] if path is None else path[:]
356 f = None 357 f = None
357 if inpackage: 358 if inpackage:
358 try: 359 try:
359 f, file, (suff, mode, type) = \ 360 f, file, (suff, mode, type) = \
360 ClassBrowsers.find_module(module, path) 361 ClassBrowsers.find_module(module, path)
361 except ImportError: 362 except ImportError:
362 f = None 363 f = None
363 if f is None: 364 if f is None:
364 fullpath = list(path) + sys.path 365 fullpath = path[:] + sys.path[:]
365 f, file, (suff, mode, type) = \ 366 f, file, (suff, mode, type) = \
366 ClassBrowsers.find_module(module, fullpath, isPyFile) 367 ClassBrowsers.find_module(module, fullpath, isPyFile)
367 if module.endswith(".py") and type == imp.PKG_DIRECTORY: 368 if module.endswith(".py") and type == imp.PKG_DIRECTORY:
368 return dictionary 369 return dictionary
369 if type == imp.PKG_DIRECTORY: 370 if type == imp.PKG_DIRECTORY:

eric ide

mercurial