Compare commits

...

5 Commits

6 changed files with 29 additions and 17 deletions

View File

@ -3,7 +3,7 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
platform: [macos-latest, ubuntu-latest, windows-latest] platform: [macos-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -12,6 +12,6 @@ jobs:
python-version: "3.6" python-version: "3.6"
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: "3.10" python-version: "3.11"
- run: python -m pip install --upgrade tox - run: python -m pip install --upgrade tox
- run: tox - run: tox

View File

@ -128,6 +128,8 @@ see the ["resource forks" section of the mac_file_format_docs repo](https://gith
* Added `open` and `open_raw` methods to `Resource` objects, * Added `open` and `open_raw` methods to `Resource` objects,
for stream-based access to resource data. for stream-based access to resource data.
* Fixed reading of compressed resource headers with the header length field incorrectly set to 0
(because real Mac OS apparently accepts this).
### Version 1.8.0 ### Version 1.8.0

View File

@ -18,6 +18,7 @@ classifiers =
Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Software Development :: Disassemblers Topic :: Software Development :: Disassemblers
Topic :: System Topic :: System
Topic :: Utilities Topic :: Utilities
@ -66,15 +67,24 @@ extend-exclude =
# The following issues are ignored because they do not match our code style: # The following issues are ignored because they do not match our code style:
ignore = ignore =
# These E1 checks report many false positives for code that is (consistently) indented with tabs alone. # These E1 checks report many false positives for code that is (consistently) indented with tabs alone.
E101, # indentation contains mixed spaces and tabs # indentation contains mixed spaces and tabs
E117, # over-indented E101,
E126, # continuation line over-indented for hanging indent # over-indented
E226, # missing whitespace around arithmetic operator E117,
E261, # at least two spaces before inline comment # continuation line over-indented for hanging indent
E501, # line too long E126,
W191, # indentation contains tabs # missing whitespace around arithmetic operator
W293, # blank line contains whitespace E226,
W503, # line break before binary operator # at least two spaces before inline comment
E261,
# line too long
E501,
# indentation contains tabs
W191,
# blank line contains whitespace
W293,
# line break before binary operator
W503,
[mypy] [mypy]
files=src/**/*.py files=src/**/*.py

View File

@ -152,12 +152,12 @@ class Resource(object):
@property @property
def resource_type(self) -> bytes: def resource_type(self) -> bytes:
warnings.warn(DeprecationWarning("The resource_type attribute has been deprecated and will be removed in a future version. Please use the type attribute instead.")) warnings.warn(DeprecationWarning("The resource_type attribute has been deprecated and will be removed in a future version. Please use the type attribute instead."), stacklevel=2)
return self.type return self.type
@property @property
def resource_id(self) -> int: def resource_id(self) -> int:
warnings.warn(DeprecationWarning("The resource_id attribute has been deprecated and will be removed in a future version. Please use the id attribute instead.")) warnings.warn(DeprecationWarning("The resource_id attribute has been deprecated and will be removed in a future version. Please use the id attribute instead."), stacklevel=2)
return self.id return self.id
@property @property
@ -369,7 +369,7 @@ class ResourceFile(typing.Mapping[bytes, typing.Mapping[int, Resource]], typing.
fork = "rsrc" fork = "rsrc"
else: else:
fork = "data" fork = "data"
warnings.warn(DeprecationWarning(f"The rsrcfork parameter has been deprecated and will be removed in a future version. Please use fork={fork!r} instead of rsrcfork={kwargs['rsrcfork']!r}.")) warnings.warn(DeprecationWarning(f"The rsrcfork parameter has been deprecated and will be removed in a future version. Please use fork={fork!r} instead of rsrcfork={kwargs['rsrcfork']!r}."), stacklevel=2)
del kwargs["rsrcfork"] del kwargs["rsrcfork"]
if fork == "auto": if fork == "auto":

View File

@ -46,8 +46,8 @@ class CompressedHeaderInfo(object):
raise DecompressError("Invalid header") raise DecompressError("Invalid header")
if signature != COMPRESSED_SIGNATURE: if signature != COMPRESSED_SIGNATURE:
raise DecompressError(f"Invalid signature: {signature!r}, expected {COMPRESSED_SIGNATURE!r}") raise DecompressError(f"Invalid signature: {signature!r}, expected {COMPRESSED_SIGNATURE!r}")
if header_length != 0x12: if header_length not in {0, 0x12}:
raise DecompressError(f"Unsupported header length: 0x{header_length:>04x}, expected 0x12") raise DecompressError(f"Unsupported header length value: 0x{header_length:>04x}, expected 0x12 or 0")
if compression_type == COMPRESSED_TYPE_8: if compression_type == COMPRESSED_TYPE_8:
working_buffer_fractional_size, expansion_buffer_size, dcmp_id, reserved = STRUCT_COMPRESSED_TYPE_8_HEADER.unpack(remainder) working_buffer_fractional_size, expansion_buffer_size, dcmp_id, reserved = STRUCT_COMPRESSED_TYPE_8_HEADER.unpack(remainder)

View File

@ -1,7 +1,7 @@
[tox] [tox]
# When updating the Python versions here, # When updating the Python versions here,
# please also update the corresponding Python versions in the GitHub Actions workflow (.github/workflows/ci.yml). # please also update the corresponding Python versions in the GitHub Actions workflow (.github/workflows/ci.yml).
envlist = py{36,310},flake8,mypy,package envlist = py{36,311},flake8,mypy,package
[testenv] [testenv]
commands = python -m unittest discover --start-directory ./tests commands = python -m unittest discover --start-directory ./tests