Skip to content

Commit ffc54dc

Browse files
committed
Revert "Merge pull request #787 from AndrewFasano/fix_786"
This reverts commit bbfca4e, reversing changes made to 61f6925.
1 parent bbfca4e commit ffc54dc

File tree

4 files changed

+7
-32
lines changed

4 files changed

+7
-32
lines changed

tests/test_file_utils.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,6 @@ def fake_file() -> File:
8181
return File.from_bytes(b"0123456789abcdefghijklmnopqrst")
8282

8383

84-
class TestFile:
85-
def test_file_from_empty_bytes(self):
86-
with pytest.raises(InvalidInputFormat):
87-
File.from_bytes(b"")
88-
89-
def test_file_from_empty_file(self, tmp_path):
90-
file_path = tmp_path / "file"
91-
file_path.touch()
92-
with pytest.raises(InvalidInputFormat):
93-
File.from_path(file_path)
94-
95-
9684
class TestStructParser:
9785
def test_parse_correct_endianness(self):
9886
test_content = b"\x01\x02\x03\x04"

unblob/file_utils.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ class SeekError(ValueError):
4040
"""Specific ValueError for File.seek."""
4141

4242

43-
class InvalidInputFormat(Exception):
44-
pass
45-
46-
4743
class File(mmap.mmap):
4844
access: int
4945

5046
@classmethod
5147
def from_bytes(cls, content: bytes):
52-
if not content:
53-
raise InvalidInputFormat("Can't create File from empty bytes.")
5448
m = cls(-1, len(content))
5549
m.write(content)
5650
m.seek(0)
@@ -61,10 +55,7 @@ def from_bytes(cls, content: bytes):
6155
def from_path(cls, path: Path, access=mmap.ACCESS_READ):
6256
mode = "r+b" if access == mmap.ACCESS_WRITE else "rb"
6357
with path.open(mode) as base_file:
64-
try:
65-
m = cls(base_file.fileno(), 0, access=access)
66-
except ValueError as exc:
67-
raise InvalidInputFormat from exc
58+
m = cls(base_file.fileno(), 0, access=access)
6859
m.access = access
6960
return m
7061

@@ -124,6 +115,10 @@ def tell(self):
124115
return self._file.tell() - self._offset
125116

126117

118+
class InvalidInputFormat(Exception):
119+
pass
120+
121+
127122
class Endian(enum.Enum):
128123
LITTLE = "<"
129124
BIG = ">"

unblob/handlers/archive/sevenzip.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ class MultiVolumeSevenZipHandler(DirectoryHandler):
107107

108108
def calculate_multifile(self, file: Path) -> Optional[MultiFile]:
109109
paths = sorted(
110-
[
111-
p
112-
for p in file.parent.glob(f"{file.stem}.*")
113-
if p.resolve().exists() and p.stat().st_size > 0
114-
]
110+
[p for p in file.parent.glob(f"{file.stem}.*") if p.resolve().exists()]
115111
)
116112
if not paths:
117113
return None

unblob/handlers/compression/gzip.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,7 @@ def is_valid_gzip(self, path: Path) -> bool:
167167

168168
def calculate_multifile(self, file: Path) -> Optional[MultiFile]:
169169
paths = sorted(
170-
[
171-
p
172-
for p in file.parent.glob(f"{file.stem}.*")
173-
if p.resolve().exists() and p.stat().st_size > 0
174-
]
170+
[p for p in file.parent.glob(f"{file.stem}.*") if p.resolve().exists()]
175171
)
176172

177173
# we 'discard' paths that are not the first in the ordered list,

0 commit comments

Comments
 (0)