tools/cr/cr/loader.py
def _ScanPackage(package):
  """Scan a package for child packages and modules."""
  modules = []
  # Recurse sub folders.
  for path in package.__path__:
    try:
      basenames = sorted(os.listdir(path))
    except OSError:
      basenames = []
    packages = []
    for basename in basenames:
      fullpath = os.path.join(path, basename)
      if os.path.isdir(fullpath):
        name = '.'.join([package.__name__, basename])
        packages.append(name)
      elif basename.endswith('.py') and not basename.startswith('_'):
        name = '.'.join([package.__name__, basename[:-3]])
        module = _TryImport(name)
        if module:
          _ScanModule(module)
          modules.append(module)
    for name in packages:
      child = _TryImport(name)
      if child:
        modules.extend(_ScanPackage(child))
  return modules
Scan a package for child packages and modules.
Scan a package for child packages and modules.
Scan a package for child packages and modules .
def _ScanPackage(package):
  modules = []
  for path in package.__path__:
    try:
      basenames = sorted(os.listdir(path))
    except OSError:
      basenames = []
    packages = []
    for basename in basenames:
      fullpath = os.path.join(path, basename)
      if os.path.isdir(fullpath):
        name = '.'.join([package.__name__, basename])
        packages.append(name)
      elif basename.endswith('.py') and not basename.startswith('_'):
        name = '.'.join([package.__name__, basename[:-3]])
        module = _TryImport(name)
        if module:
          _ScanModule(module)
          modules.append(module)
    for name in packages:
      child = _TryImport(name)
      if child:
        modules.extend(_ScanPackage(child))
  return modules
def _ScanPackage ( package ) : modules = [ ] for path in package . __path__ : try : basenames = sorted ( os . listdir ( path ) ) except OSError : basenames = [ ] packages = [ ] for basename in basenames : fullpath = os . path . join ( path , basename ) if os . path . isdir ( fullpath ) : name = '.' . join ( [ package . __name__ , basename ] ) packages . append ( name ) elif basename . endswith ( '.py' ) and not basename . startswith ( '_' ) : name = '.' . join ( [ package . __name__ , basename [ : - 3 ] ] ) module = _TryImport ( name ) if module : _ScanModule ( module ) modules . append ( module ) for name in packages : child = _TryImport ( name ) if child : modules . extend ( _ScanPackage ( child ) ) return modules
Scan a package for child packages and modules.
Scan a package for child packages and modules .
"""Scan a package for child packages and modules.""" # Recurse sub folders.
package