Retrieves directory entries.

    Since a directory can contain a vast number of entries using
    a generator is more memory efficient.

    Yields:
      FakePathSpec: a path specification.
545106
def _EntriesGenerator(self):
    
    location = getattr(self.path_spec, 'location', None)
    if location is not None:
      paths = self._file_system.GetPaths()

      for path in iter(paths.keys()):
        # Determine if the start of the path is similar to the location string.
        # If not the file the path refers to is not in the same directory.
        if not path or not path.startswith(location):
          continue

        _, suffix = self._file_system.GetPathSegmentAndSuffix(location, path)

        # Ignore anything that is part of a sub directory or the directory
        # itself.
        if suffix or path == location:
          continue

        path_spec_location = self._file_system.JoinPath([path])
        yield fake_path_spec.FakePathSpec(location=path_spec_location)
279382
def _get_mnist(directory):
  """"""
  for filename in [
      _MNIST_TRAIN_DATA_FILENAME, _MNIST_TRAIN_LABELS_FILENAME,
      _MNIST_TEST_DATA_FILENAME, _MNIST_TEST_LABELS_FILENAME
  ]:
    generator_utils.maybe_download(directory, filename, _MNIST_URL + filename)
404652
def _get_files(self) -> Iterator[str]:
        
        path = os.path.abspath(self.path)
        if os.path.isfile(path):
            path = os.path.dirname(path)

        for path in self._get_parents(path):
            for file_path in self._get_files_from_dir(path):
                yield file_path
321284
def _GeneratorFromPath(path):
  """"""
  if not path:
    raise ValueError('path must be a valid string')
  if io_wrapper.IsTensorFlowEventsFile(path):
    return event_file_loader.EventFileLoader(path)
  else:
    return directory_watcher.DirectoryWatcher(
        path,
        event_file_loader.EventFileLoader,
        io_wrapper.IsTensorFlowEventsFile)
784850
function getEntries(dirName) {
  const entries = {};
  getExamples(dirName, (entryName, filename) => {
    entries[entryName] = filename;
  });
  return entries;
}
439615
def get_dirs_for_path(*paths):
    
    for path in paths:
        head = path
        while head:
            head, tail = os.path.split(head)
            if head:
                yield head
            else:
                # We don't need to yield empty path
                break
510527
def files(self, paths, access=None, extensions=None,
              minsize=None, recursion=False):
        
        self.__init__()
        self.access = access
        self.filetype = 'file'
        self.extensions = extensions
        self.minsize = minsize
        self.paths = paths
        self.recursion = recursion

        return _sorter(self._generator_file())
622569
def get_entries(dir, subfolder)
      base = site.in_source_dir(dir, subfolder)
      return [] unless File.exist?(base)

      entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
      entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
    end
710535
def iterSourceCode(paths):
    
    for path in paths:
        if os.path.isdir(path):
            for dirpath, dirnames, filenames in os.walk(path):
                for filename in filenames:
                    full_path = os.path.join(dirpath, filename)
                    if isPythonFile(full_path):
                        yield full_path
        else:
            yield path
44244
def _GetDirectory(self):
    
    if self.entry_type != definitions.FILE_ENTRY_TYPE_DIRECTORY:
      return None
    return TSKDirectory(self._file_system, self.path_spec)
1144359
def find_directory_manifest(dirname)
      entries = File.directory?(dirname) ? Dir.entries(dirname) : []
      entry = entries.find { |e| e =~ MANIFEST_RE } ||
        generate_manifest_path
      File.join(dirname, entry)
    end
194966
def GetFileEntryByPathSpec(self, path_spec):
    
    store_index = vshadow.VShadowPathSpecGetStoreIndex(path_spec)

    # The virtual root file has not corresponding store index but
    # should have a location.
    if store_index is None:
      location = getattr(path_spec, 'location', None)
      if location is None or location != self.LOCATION_ROOT:
        return None

      return vshadow_file_entry.VShadowFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    if store_index < 0 or store_index >= self._vshadow_volume.number_of_stores:
      return None

    return vshadow_file_entry.VShadowFileEntry(
        self._resolver_context, self, path_spec)
231090
def directory_walk(source_d, destination_d):
    '''
    
    '''
    for dirpath, dirnames, filenames in os.walk(source_d):
        relpath = os.path.relpath(dirpath, source_d)
        if relpath == '.':
            relpath = ''  # remove implied '.'
        for filename in filenames:
            suffix = filename
            if relpath:
                suffix = os.path.join(relpath, filename)
            full_source_path = os.path.join(source_d, suffix)
            full_destination_path = os.path.join(destination_d, suffix)
            yield full_source_path, full_destination_path
141498
def get_results_path(self):
        
        result_path = os.path.join(RESULTS_ROOT, self.uuid)
        if not os.path.exists(result_path):
            os.makedirs(result_path)
        return result_path
865074
def GetFileEntryByPathSpec(self, path_spec):
    
    location = getattr(path_spec, 'location', None)

    if (location is None or
        not location.startswith(self.LOCATION_ROOT)):
      return None

    if len(location) == 1:
      return cpio_file_entry.CPIOFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    cpio_archive_file_entry = self._cpio_archive_file.GetFileEntryByPath(
        location[1:])
    if cpio_archive_file_entry is None:
      return None

    return cpio_file_entry.CPIOFileEntry(
        self._resolver_context, self, path_spec,
        cpio_archive_file_entry=cpio_archive_file_entry)
1164834
def _get_memory_banks_listed_in_dir(path):
    """"""
    # Such directories contain entries named "node<id>" for each memory bank
    return [int(entry[4:]) for entry in os.listdir(path) if entry.startswith('node')]
980436
def GetFileEntries(self, path_prefix=''):
    
    if self._file_entries:
      for path, file_entry in iter(self._file_entries.items()):
        if path.startswith(path_prefix):
          yield file_entry