Lines Matching refs:path

9 import os.path
53 def walk_packages(path=None, prefix='', onerror=None):
55 on path, or, if path is None, all accessible modules.
57 'path' should be either None or a list of paths to look for
64 modules!) on the given path, in order to access the __path__
87 for info in iter_modules(path, prefix):
102 path = getattr(sys.modules[info.name], '__path__', None) or []
104 # don't traverse path items we've seen before
105 path = [p for p in path if not seen(p)]
107 yield from walk_packages(path, info.name+'.', onerror)
110 def iter_modules(path=None, prefix=''):
111 """Yields ModuleInfo for all submodules on path,
112 or, if path is None, all top-level modules on sys.path.
114 'path' should be either None or a list of paths to look for
120 if path is None:
122 elif isinstance(path, str):
123 raise ValueError("path must be None or list of paths to look for "
126 importers = map(get_importer, path)
143 # Implement a file walker for the normal importlib path hook
145 if importer.path is None or not os.path.isdir(importer.path):
151 filenames = os.listdir(importer.path)
162 path = os.path.join(importer.path, fn)
165 if not modname and os.path.isdir(path) and '.' not in fn:
168 dircontents = os.listdir(path)
199 the current sys.path, plus any modules that are frozen or built-in.
205 def __init__(self, path=None):
211 self.path = path
213 def find_module(self, fullname, path=None):
214 # Note: we ignore 'path' argument since it is only used via meta_path
216 if subname != fullname and self.path is None:
218 if self.path is None:
219 path = None
221 path = [os.path.realpath(self.path)]
223 file, filename, etc = imp.find_module(subname, path)
229 if self.path is None or not os.path.isdir(self.path):
235 filenames = os.listdir(self.path)
246 path = os.path.join(self.path, fn)
249 if not modname and os.path.isdir(path) and '.' not in fn:
252 dircontents = os.listdir(path)
347 if os.path.exists(self.filename[:-1]):
408 """Retrieve a finder for the given path item
411 if it was newly created by a path hook.
451 path = getattr(pkg, '__path__', None)
452 if path is None:
456 path = sys.path
457 for item in path:
506 def extend_path(path, name):
507 """Extend a package's path.
514 For each directory on sys.path that has a subdirectory that
524 path, regardless of whether they are exist the filesystem. (This
527 If the input path is not a list (as is the case for frozen
528 packages) it is returned unchanged. The input path is not
532 It is assumed that sys.path is a sequence. Items of sys.path that
534 directories are ignored. Unicode items of sys.path that cause
536 exception (in line with os.path.isdir() behavior).
539 if not isinstance(path, list):
541 # frozen package. Return the path unchanged in that case.
542 return path
546 path = path[:] # Start with a copy of the existing path
555 return path
557 search_path = sys.path
575 # XXX This may still add duplicate entries to path on
577 if portion not in path:
578 path.append(portion)
582 pkgfile = os.path.join(dir, sname_pkg)
583 if os.path.isfile(pkgfile):
595 path.append(line) # Don't check for existence!
597 return path
606 filename, using '/' as the path separator. The parent directory name '..'
615 d = os.path.dirname(sys.modules[package].__file__)
616 data = open(os.path.join(d, resource), 'rb').read()
635 # signature - an os.path format "filename" starting with the dirname of
638 parts.insert(0, os.path.dirname(mod.__file__))
639 resource_name = os.path.join(*parts)