Commit Graph

183 Commits

Author SHA1 Message Date
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
dgelessus
a45dbd8eca Remove upgrade of pip from CI workflow
The GitHub Actions environment clearly has a working pip pre-installed,
and it's unlikely that this project relies on any extremely new
features.
2020-01-19 19:59:42 +01:00
dgelessus
3401ce65dd Update actions/checkout to v2 2020-01-19 19:38:29 +01:00
dgelessus
890dd24f76 Also run CI workflow on pull requests 2020-01-19 19:36:53 +01:00
dgelessus
67c2b4acf0 Add test case for additional resource file and resource metadata 2020-01-19 19:22:59 +01:00
dgelessus
238c78a73e Simplify attribute asserts in tests 2020-01-19 19:05:05 +01:00
dgelessus
fbd861edf4 Fix test_textclipping not checking resource ID lists properly
Because Python's zip terminates once *any* of the input iterables
terminates, the previous code would not detect if the file was missing
resources or contained extra ones.
2020-01-19 02:30:10 +01:00
dgelessus
a7a407a1dd Add extra assertion to test_textclipping 2019-12-30 03:04:48 +01:00
dgelessus
ecee2616cf Add flake8-bugbear plugin 2019-12-30 03:04:27 +01:00
dgelessus
ba284d1800 Fix a bunch of flake8 violations 2019-12-30 03:00:12 +01:00
dgelessus
f690caac24 Add flake8 configuration 2019-12-30 02:57:31 +01:00