def _sub_modules_dict(self): """ Lists modules in the directory of this module (if this module is a package). """ names = {} try: method = self.py__path__ except AttributeError: pass else: for path in method(): mods = iter_modules([path]) for module_loader, name, is_pkg in mods: # It's obviously a relative import to the current module. names[name] = SubModuleName(self, name) # TODO add something like this in the future, its cleaner than the # import hacks. # ``os.path`` is a hardcoded exception, because it's a # ``sys.modules`` modification. # if str(self.name) == 'os': # names.append(Name('path', parent_context=self)) return names
def _sub_modules_dict(self): """ Lists modules in the directory of this module (if this module is a package). """ path = self._path names = {} if path is not None and path.endswith(os.path.sep + '__init__.py'): mods = iter_modules([os.path.dirname(path)]) for module_loader, name, is_pkg in mods: # It's obviously a relative import to the current module. names[name] = SubModuleName(self, name) # TODO add something like this in the future, its cleaner than the # import hacks. # ``os.path`` is a hardcoded exception, because it's a # ``sys.modules`` modification. # if str(self.name) == 'os': # names.append(Name('path', parent_context=self)) return names
def list_module_names(inference_state, search_path): return [ force_unicode(name) for module_loader, name, is_pkg in iter_modules(search_path) ]
def list_module_names(evaluator, search_path): return [ force_unicode(name) for module_loader, name, is_pkg in iter_modules(search_path) ]
def list_module_names(evaluator, search_path): return [name for module_loader, name, is_pkg in iter_modules(search_path)]
def list_module_names(evaluator, search_path): return [ name for module_loader, name, is_pkg in iter_modules(search_path) ]