(root, path_filter=None, ignore_hidden=True)
Scans a directory tree for files.

  Args:
    root: str, Path to a root directory.
    path_filter: A regular expression filter.  If set, only paths matching
      the path_filter are returned.
    ignore_hidden: If True, do not follow or return hidden directories or files
      (those starting with a '.' character).

  Yields:
    A string path to files, relative to cwd.
Scans a directory tree for files.
Scans a directory tree for files .
def ScanTree(root, path_filter=None, ignore_hidden=True):
  """Scans a directory tree for files.

  Args:
    root: str, Path to a root directory.
    path_filter: A regular expression filter.  If set, only paths matching
      the path_filter are returned.
    ignore_hidden: If True, do not follow or return hidden directories or files
      (those starting with a '.' character).

  Yields:
    A string path to files, relative to cwd.
  """

  def OnError(os_error):
    raise os_error

  for dirpath, dirnames, filenames in os.walk(root, onerror=OnError):
    # os.walk allows us to modify dirnames to prevent decent into particular
    # directories.  Avoid hidden directories.
    for dirname in dirnames:
      if ignore_hidden and dirname.startswith('.'):
        dirnames.remove(dirname)

    for filename in filenames:

      # nothing that starts with '.'
      if ignore_hidden and filename.startswith('.'):
        continue

      fullpath = os.path.join(dirpath, filename)

      if path_filter and not path_filter.match(fullpath):
        continue

      yield os.path.normpath(fullpath)
def ScanTree ( root , path_filter = None , ignore_hidden = True ) : def OnError ( os_error ) : raise os_error for dirpath , dirnames , filenames in os . walk ( root , onerror = OnError ) : # os.walk allows us to modify dirnames to prevent decent into particular # directories.  Avoid hidden directories. for dirname in dirnames : if ignore_hidden and dirname . startswith ( '.' ) : dirnames . remove ( dirname ) for filename in filenames : # nothing that starts with '.' if ignore_hidden and filename . startswith ( '.' ) : continue fullpath = os . path . join ( dirpath , filename ) if path_filter and not path_filter . match ( fullpath ) : continue yield os . path . normpath ( fullpath )