src/eric7/Utilities/ClassBrowsers/pyclbr.py

branch
eric7
changeset 9490
77b8d3a635b7
parent 9473
3f23dbf37dbe
child 9500
5771348ded12
equal deleted inserted replaced
9489:c03b8323d11a 9490:77b8d3a635b7
140 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub 140 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub
141 141
142 _modules = {} # cache of modules we've seen 142 _modules = {} # cache of modules we've seen
143 143
144 144
145 def clearModulesCache():
146 """
147 Function to clear the cached modules.
148 """
149 _modules.clear()
150
151
145 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase): 152 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase):
146 """ 153 """
147 Mixin class implementing the notion of visibility. 154 Mixin class implementing the notion of visibility.
148 """ 155 """
149 156
352 self.importedNames[name] = [lineno] 359 self.importedNames[name] = [lineno]
353 else: 360 else:
354 self.importedNames[name].append(lineno) 361 self.importedNames[name].append(lineno)
355 362
356 363
357 def readmodule_ex(module, path=None, inpackage=False, isPyFile=False): 364 def readmodule_ex(module, path=None, isTypeFile=False):
358 """ 365 """
359 Read a module file and return a dictionary of classes. 366 Read a module file and return a dictionary of classes.
360 367
361 Search for MODULE in PATH and sys.path, read and parse the 368 Search for MODULE in PATH and sys.path, read and parse the
362 module and return a dictionary with one entry for each class 369 module and return a dictionary with one entry for each class
364 371
365 @param module name of the module file 372 @param module name of the module file
366 @type str 373 @type str
367 @param path path the module should be searched in 374 @param path path the module should be searched in
368 @type list of str 375 @type list of str
369 @param inpackage flag indicating a module inside a package is scanned 376 @param isTypeFile flag indicating a file of this type
370 @type bool
371 @param isPyFile flag indicating a Python file
372 @type bool 377 @type bool
373 @return the resulting dictionary 378 @return the resulting dictionary
374 @rtype dict 379 @rtype dict
375 """ 380 """
376 global _modules 381 global _modules
384 return {} 389 return {}
385 390
386 # search the path for the module 391 # search the path for the module
387 path = [] if path is None else path[:] 392 path = [] if path is None else path[:]
388 f = None 393 f = None
389 if inpackage:
390 try:
391 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, path)
392 except ImportError:
393 f = None
394 if f is None: 394 if f is None:
395 fullpath = path[:] + sys.path[:] 395 fullpath = path[:] + sys.path[:]
396 f, file, (suff, mode, type) = ClassBrowsers.find_module( 396 f, file, (suff, mode, type) = ClassBrowsers.find_module(
397 module, fullpath, isPyFile 397 module, fullpath, isTypeFile
398 ) 398 )
399 if f: 399 if f:
400 f.close() 400 f.close()
401 if type not in SUPPORTED_TYPES: 401 if type not in SUPPORTED_TYPES:
402 # not Python source, can't do anything with this module 402 # not Python source, can't do anything with this module

eric ide

mercurial