Esempio n. 1
0
  def GetFileEntryByPathSpec(self, path_spec):
    """Retrieves a file entry for a path specification.

    Args:
      path_spec (PathSpec): path specification of the file entry.

    Returns:
      ZipFileEntry: a file entry or None.
    """
    if not self.FileEntryExistsByPathSpec(path_spec):
      return None

    location = getattr(path_spec, 'location', None)

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

    kwargs = {}
    try:
      kwargs['zip_info'] = self._zip_file.getinfo(location[1:])
    except KeyError:
      kwargs['is_virtual'] = True

    return zip_file_entry.ZipFileEntry(
        self._resolver_context, self, path_spec, **kwargs)
Esempio n. 2
0
    def testIntialize(self):
        """Test the initialize functionality."""
        file_entry = zip_file_entry.ZipFileEntry(self._resolver_context,
                                                 self._file_system,
                                                 self._zip_path_spec)

        self.assertNotEqual(file_entry, None)
Esempio n. 3
0
  def testIntialize(self):
    """Test the __init__ function."""
    file_entry = zip_file_entry.ZipFileEntry(
        self._resolver_context, self._file_system, self._zip_path_spec,
        is_virtual=True)

    self.assertIsNotNone(file_entry)