1466 if lineno not in self.linenos: |
1466 if lineno not in self.linenos: |
1467 self.linenos.append(lineno) |
1467 self.linenos.append(lineno) |
1468 |
1468 |
1469 |
1469 |
1470 def readModule(module, path=None, inpackage=False, basename="", |
1470 def readModule(module, path=None, inpackage=False, basename="", |
1471 extensions=None, caching=True): |
1471 extensions=None, caching=True, ignoreBuiltinModules=False): |
1472 """ |
1472 """ |
1473 Function to read a module file and parse it. |
1473 Function to read a module file and parse it. |
1474 |
1474 |
1475 The module is searched in path and sys.path, read and parsed. |
1475 The module is searched in path and sys.path, read and parsed. |
1476 If the module was parsed before, the information is taken |
1476 If the module was parsed before, the information is taken |
1484 the module file to be read (string) |
1484 the module file to be read (string) |
1485 @param extensions list of extensions, which should be considered valid |
1485 @param extensions list of extensions, which should be considered valid |
1486 source file extensions (list of strings) |
1486 source file extensions (list of strings) |
1487 @param caching flag indicating that the parsed module should be |
1487 @param caching flag indicating that the parsed module should be |
1488 cached (boolean) |
1488 cached (boolean) |
|
1489 @param ignoreBuiltinModules flag indicating to ignore the builtin modules |
|
1490 (boolean) |
1489 @return reference to a Module object containing the parsed |
1491 @return reference to a Module object containing the parsed |
1490 module information (Module) |
1492 module information (Module) |
1491 """ |
1493 """ |
1492 global _modules |
1494 global _modules |
1493 |
1495 |
1527 |
1529 |
1528 if caching and modname in _modules: |
1530 if caching and modname in _modules: |
1529 # we've seen this module before... |
1531 # we've seen this module before... |
1530 return _modules[modname] |
1532 return _modules[modname] |
1531 |
1533 |
1532 if module in sys.builtin_module_names: |
1534 if not ignoreBuiltinModules and module in sys.builtin_module_names: |
1533 # this is a built-in module |
1535 # this is a built-in module |
1534 mod = Module(modname, None, None) |
1536 mod = Module(modname, None, None) |
1535 if caching: |
1537 if caching: |
1536 _modules[modname] = mod |
1538 _modules[modname] = mod |
1537 return mod |
1539 return mod |