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 |
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 |