Skip to content

Commit

Permalink
Merge pull request #127 from Changaco/fix-attribute-error
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco authored Mar 5, 2024
2 parents ed0e591 + 4d72c7d commit 5f7008d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 0 additions & 4 deletions libarchive/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,6 @@ def rdevminor(self):
def rdevminor(self, value):
ffi.entry_set_rdevminor(self._entry_p, value)

@property
def format_name(self):
return ffi.format_name(self._pointer)


class ConsumedArchiveEntry(ArchiveEntry):

Expand Down
4 changes: 4 additions & 0 deletions libarchive/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def filter_names(self):
count = ffi.filter_count(self._pointer)
return [ffi.filter_name(self._pointer, i) for i in range(count - 1)]

@property
def format_name(self):
return ffi.format_name(self._pointer)


@contextmanager
def new_archive_read(format_name='all', filter_name='all', passphrase=None):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_rwx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def test_buffers(tmpdir):
# Read the archive and check that the data is correct
with libarchive.memory_reader(buf) as archive:
check_archive(archive, tree)
assert archive.format_name == b'GNU tar format'
assert archive.filter_names == [b'xz']

# Extract the archive in tmpdir and check that the data is intact
with in_dir(tmpdir.strpath):
Expand All @@ -50,6 +52,8 @@ def test_fd(tmpdir):
archive_file.seek(0)
with libarchive.fd_reader(fd) as archive:
check_archive(archive, tree)
assert archive.format_name == b'GNU tar format'
assert archive.filter_names == [b'bzip2']

# Extract the archive in tmpdir and check that the data is intact
archive_file.seek(0)
Expand All @@ -73,6 +77,8 @@ def test_files(tmpdir):
# Read the archive and check that the data is correct
with libarchive.file_reader(archive_path) as archive:
check_archive(archive, tree)
assert archive.format_name == b'POSIX ustar format'
assert archive.filter_names == [b'gzip']

# Extract the archive in tmpdir and check that the data is intact
with in_dir(tmpdir.strpath):
Expand All @@ -95,6 +101,8 @@ def test_custom_writer_and_stream_reader():
# Read the archive and check that the data is correct
with libarchive.stream_reader(stream, 'zip') as archive:
check_archive(archive, tree)
assert archive.format_name == b'ZIP 2.0 (deflation)'
assert archive.filter_names == []


@patch('libarchive.ffi.write_fail')
Expand Down

0 comments on commit 5f7008d

Please sign in to comment.