def GetFileEntryByPathSpec(self, path_spec): """Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: TARFileEntry: file entry or None. """ if not self.FileEntryExistsByPathSpec(path_spec): return None location = getattr(path_spec, 'location', None) if len(location) == 1: return tar_file_entry.TARFileEntry(self._resolver_context, self, path_spec, is_root=True, is_virtual=True) kwargs = {} try: kwargs['tar_info'] = self._tar_file.getmember(location[1:]) except KeyError: kwargs['is_virtual'] = True return tar_file_entry.TARFileEntry(self._resolver_context, self, path_spec, **kwargs)
def testIntialize(self): """Test the initialize functionality.""" file_entry = tar_file_entry.TARFileEntry(self._resolver_context, self._file_system, self._tar_path_spec) self.assertIsNotNone(file_entry)
def testSize(self): """Test the size property.""" file_entry = tar_file_entry.TARFileEntry(self._resolver_context, self._file_system, self._tar_path_spec) self.assertIsNotNone(file_entry) self.assertEqual(file_entry.size, 1247)
def testModificationTime(self): """Test the modification_time property.""" file_entry = tar_file_entry.TARFileEntry(self._resolver_context, self._file_system, self._tar_path_spec) self.assertIsNotNone(file_entry) self.assertIsNotNone(file_entry.modification_time)
def testName(self): """Test the name property.""" file_entry = tar_file_entry.TARFileEntry(self._resolver_context, self._file_system, self._tar_path_spec) self.assertIsNotNone(file_entry) self.assertEqual(file_entry.name, 'syslog')