Commit Graph

193 Commits

Author SHA1 Message Date
dgelessus
0624d4eae9 Mark Python 3.11 as supported 2023-02-14 21:09:17 +01:00
dgelessus
4ad1d1d6b9 Update GitHub Actions to current versions 2022-09-08 11:04:47 +02:00
dgelessus
b95c4917cc Fix new mypy error about enum.Flag.name possibly being None 2022-09-08 11:03:52 +02:00
dgelessus
ee767a106c Remove flake8-tabs plugin that is incompatible with flake8 5
And instead manually ignore the relevant indentation errors/warnings.
2022-09-08 10:46:45 +02:00
dgelessus
82951f5d8e Update usage examples in README.md 2022-09-08 10:42:42 +02:00
dgelessus
b9fdac1c0b Wrap some long lines in README.md for better diffing/merging 2022-09-08 10:38:39 +02:00
dgelessus
70d51c2907 Convert README from reStructuredText to Markdown
Because it doesn't use any reStructuredText-specific features and
Markdown syntax is less annoying.
2022-09-08 10:30:21 +02:00
dgelessus
f891a6ee00 Move main source code into src subdirectory
This avoids certain problems related to the entire repo root appearing
on the import path, usually when running Python/pip from the repo root
or when using an editable install.
2021-11-21 19:15:51 +01:00
dgelessus
b1e5e7c96e Update actions/setup-python to v2 2021-11-21 18:50:34 +01:00
dgelessus
60709e386a Add Python 3.10 to test matrix and classifiers 2021-11-21 18:48:12 +01:00
dgelessus
f437ee5f43 Reduce test matrix to just the oldest and newest Python versions
Testing the versions in between doesn't really bring much benefit, and
it becomes impractical when the range of supported versions grows.
2021-11-21 18:24:17 +01:00
dgelessus
5c3bc5d7e5 Remove custom stream types and read all resource data upfront again
The custom stream types were almost always slower than just reading the
entire data into memory, and there's no reason not to do that -
resources are small enough that memory usage and disk IO speed aren't a
concern (at least not for any machine that's modern enough to run
Python 3...).

Perhaps the only performance advantage was when reading a small amount
of data from the start of a compressed resource. In that case the
custom stream could incrementally decompress only the part of the data
that's actually needed, which was a bit faster than decompressing the
entire resource and then throwing away most of the data. But this
situation is rare enough that it's not worth handling in the rsrcfork
library. If this is a real performance issue for someone, they can
manually call the incremental decompression functions from
rsrcfork.compress where needed.
2020-11-01 19:28:25 +01:00
dgelessus
d74dbc41ba Remove no longer needed type: ignore comment from .__main__ 2020-11-01 19:13:11 +01:00
dgelessus
0642b1e8bf Add Python 3.9 to test matrix and classifiers 2020-11-01 19:09:43 +01:00
dgelessus
54ccdb0a47 Add Typing :: Typed classifier 2020-08-08 19:36:23 +02:00
dgelessus
f76817c389 Reorder classifiers alphabetically 2020-08-08 19:30:26 +02:00
dgelessus
9e6dfacff6 Add custom stream type for compressed resources 2020-08-01 14:11:06 +02:00
dgelessus
8d39469e6e Wrap _io_utils.SubStream in an io.BufferedReader for performance
Although the underlying stream is already buffered, the extra
BufferedReader wrapper around the SubStream results in a noticeable
performance improvement.
2020-07-23 15:49:28 +02:00
dgelessus
028be98e8d Suppress incorrect mypy shutil.copyfileobj error (python/mypy#8962) 2020-07-23 13:31:57 +02:00
dgelessus
98551263b3 Work around false mypy error about SubStream.__enter__ 2020-07-23 13:21:34 +02:00
dgelessus
0054d0f7b5 Fix variable naming conflict in show_filtered_resources
mypy does not like it when the same variable name is used for different
types, even if it is in unrelated if branches and could never actually
cause any problems.
2020-07-23 13:17:02 +02:00
dgelessus
126795239c Reimplement Resource.data_raw using a custom stream type (SubStream)
This way all reads performed on a resource data stream are forwarded
to the underlying resource file stream, with the read offsets and
lengths adjusted appropriately.
2020-07-23 02:42:32 +02:00
dgelessus
2907d9f9e8 Rewrite __main__ code to use stream-based resource reading 2020-07-21 14:45:48 +02:00
dgelessus
5c96baea29 Change (raw_)hexdump to yield lines instead of printing directly 2020-07-21 14:27:43 +02:00
dgelessus
664e992fa3 Rewrite Resource methods using stream API where appropriate 2020-07-21 14:20:50 +02:00
dgelessus
61247ec783 Add initial API and tests for stream-based resource reading
For now the stream-based API is a simple BytesIO wrapper around
data/data_raw, but it will be optimized in the future.
2020-07-21 14:12:09 +02:00
dgelessus
0f6018e4bf Move .compress.common.make_peekable and related code into ._io_utils 2020-07-19 23:16:36 +02:00
dgelessus
476a68916b Merge implementations of read_exact functions/methods
The old functions/methods still exist, so that they continue to raise
the same exceptions as before (which are different depending on
context), but they now use the same implementation internally.
2020-07-18 21:07:12 +02:00
dgelessus
4bbf2f7c14 Bump version to 1.8.1.dev 2020-07-18 17:47:48 +02:00
dgelessus
82b5926b4f Release version 1.8.0 2020-07-18 17:31:25 +02:00
dgelessus
5456013bf4 Use flake8 extend-exclude setting instead of exclude
This setting was added in flake8 3.8.0 and allows adding entries to the
exclude list without also removing the default entries.
2020-07-18 13:40:15 +02:00
dgelessus
b595456a05 Switch back to using attr directive in setup.cfg version
As of setuptools 46.4.0, this extracts the attribute value statically
using the ast module, if possible. This allows it to work properly even
if the attribute is stored in a file that cannot be imported at setup
time (e. g. because of dependencies that might not be installed yet).
2020-07-18 13:13:19 +02:00
dgelessus
d367a9238a Add bytes_quote helper function
bytes_quote does the same as bytes_escape, but automatically adds the
quote character around the escaped string.
2020-07-07 01:03:38 +02:00
dgelessus
33c4016124 Fix flake8 problems 2020-07-07 00:04:54 +02:00
dgelessus
b01cfc77cf Don't pass required=True to add_subparsers
The required kwarg of add_subparsers was only added in Python 3.7, and
we currently still support Python 3.6.
2020-07-07 00:01:57 +02:00
dgelessus
a9f54b678c Add py.typed marker file for PEP 561
This allows type checkers like mypy to use the type hints in our code
when type-checking another project that imports this library.
2020-07-06 23:57:25 +02:00
dgelessus
b46018e666 Use is_printable in definition of _TRANSLATE_NONPRINTABLES 2020-07-06 18:01:34 +02:00
dgelessus
b0eefe3889 Replace custom CLI subcommand system with standard argparse subparsers
This is a purely internal change and should have no visible effect on
the command-line interface.
2020-07-05 19:43:01 +02:00
dgelessus
3e0bbcee04 Add Python 3.8 classifier to metadata 2020-04-19 16:21:25 +02:00
dgelessus
13654c2560 Add pyproject.toml with PEP 517/PEP 518 metadata 2020-04-19 16:21:04 +02:00
dgelessus
d5199bd503 Replace setup.cfg metadata license_file with license_files
license_file has been deprecated in wheel 0.32.0 in favor of
license_files.
2020-04-19 16:20:07 +02:00
dgelessus
c5c3f24a10 Add tox environment for building and checking distributions 2020-04-19 16:16:21 +02:00
dgelessus
7c77c4ef20 Prepare setup.py/.cfg for additional import-time dependencies
Reading the version number using attr: rsrcfork.__version__ will no
longer work properly if rsrcfork has non-stdlib dependencies at import
time, because setuptools needs to be able to import rsrcfork and read
the version number before the dependencies are installed.

As a workaround, our setup.py now manually parses the version number
from rsrcfork/__init__.py using the ast module.
2020-04-03 22:32:10 +02:00
dgelessus
f7b6080c0e Remove random execute bits from test data files 2020-04-01 00:01:50 +02:00
dgelessus
007d15eb3d Fix tox configuration breaking on spaces in the project path
The {envpython} substitution is not quoted, so spaces in the path are
treated as argument separators and cause the test runs to fail.
To work around this, we now always use an unqualified python command
instead of the {envpython} substitution. This is safe because the tox
commands are always run in a virtual environment, so the python command
is guaranteed to point to the environment's Python and not the system
default.
2020-03-30 01:46:10 +02:00
dgelessus
246b69e375 Remove accidental empty comment from test_rsrcfork.py 2020-01-21 22:32:44 +01:00
dgelessus
d67ff64851 Add tests for reading from resource forks and fork auto-selection
These tests are only run on Mac, because they require native support
for resource forks.
2020-01-21 22:29:18 +01:00
dgelessus
5391d66a78 Add tests for reading resource files from streams instead of path 2020-01-21 15:20:46 +01:00
dgelessus
5b2700bf17 Add some missing asserts to test_compress_compare 2020-01-19 23:24:52 +01:00
dgelessus
c41b25fea1 Add test case for compressed resource handling and decompression 2020-01-19 23:19:19 +01:00