Home | History | Annotate | Download | only in python2.7

Lines Matching full:path

9 import os.path
71 def walk_packages(path=None, prefix='', onerror=None):
73 on path, or, if path is None, all accessible modules.
75 'path' should be either None or a list of paths to look for
82 modules!) on the given path, in order to access the __path__
105 for importer, name, ispkg in iter_modules(path, prefix):
120 path = getattr(sys.modules[name], '__path__', None) or []
122 # don't traverse path items we've seen before
123 path = [p for p in path if not seen(p)]
125 for item in walk_packages(path, name+'.', onerror):
129 def iter_modules(path=None, prefix=''):
130 """Yields (module_loader, name, ispkg) for all submodules on path,
131 or, if path is None, all top-level modules on sys.path.
133 'path' should be either None or a list of paths to look for
140 if path is None:
143 importers = map(get_importer, path)
167 the current sys.path, plus any modules that are frozen or built-in.
173 def __init__(self, path=None):
174 self.path = path
176 def find_module(self, fullname, path=None):
177 # Note: we ignore 'path' argument since it is only used via meta_path
179 if subname != fullname and self.path is None:
181 if self.path is None:
182 path = None
184 path = [os.path.realpath(self.path)]
186 file, filename, etc = imp.find_module(subname, path)
192 if self.path is None or not os.path.isdir(self.path):
198 filenames = os.listdir(self.path)
209 path = os.path.join(self.path, fn)
212 if not modname and os.path.isdir(path) and '.' not in fn:
215 dircontents = os.listdir(path)
305 if os.path.exists(self.filename[:-1]):
367 """Retrieve a PEP 302 importer for the given path item
370 if it was newly created by a path hook.
405 sys.path, and Python's "classic" import machinery, in that order. If
411 are partially supported, but are searched AFTER sys.path. Normally,
412 these locations are searched BEFORE sys.path, preventing sys.path
416 be a module or package name that is accessible via both sys.path
431 path = getattr(sys.modules[pkg], '__path__', None) or []
435 path = sys.path
436 for item in path:
469 If fullname contains dots, path must be the containing package's __path__.
482 def extend_path(path, name):
483 """Extend a package's path.
491 directories on sys.path named after the package. This is useful
500 path, regardless of whether they are exist the filesystem. (This
503 If the input path is not a list (as is the case for frozen
504 packages) it is returned unchanged. The input path is not
508 It is assumed that sys.path is a sequence. Items of sys.path that
510 directories are ignored. Unicode items of sys.path that cause
512 exception (in line with os.path.isdir() behavior).
515 if not isinstance(path, list):
517 # frozen package. Return the path unchanged in that case.
518 return path
520 pname = os.path.join(*name.split('.')) # Reconstitute as relative path
526 path = path[:] # Start with a copy of the existing path
528 for dir in sys.path:
529 if not isinstance(dir, basestring) or not os.path.isdir(dir):
531 subdir = os.path.join(dir, pname)
532 # XXX This may still add duplicate entries to path on
534 initfile = os.path.join(subdir, init_py)
535 if subdir not in path and os.path.isfile(initfile):
536 path.append(subdir)
539 pkgfile = os.path.join(dir, sname_pkg)
540 if os.path.isfile(pkgfile):
551 path.append(line) # Don't check for existence!
554 return path
562 filename, using '/' as the path separator. The parent directory name '..'
571 d = os.path.dirname(sys.modules[package].__file__)
572 data = open(os.path.join(d, resource), 'rb').read()
586 # signature - an os.path format "filename" starting with the dirname of
589 parts.insert(0, os.path.dirname(mod.__file__))
590 resource_name = os.path.join(*parts)