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
dgelessus
3a805c3e56
Add GitHub Actions workflow for CI
2019-12-30 01:59:05 +01:00
dgelessus
6adf8eb88d
Fix mypy errors about byte strings as format string parameters
2019-12-30 01:48:33 +01:00
dgelessus
e132a91dea
Fix missing sys.exit calls in CLI subcommand functions
2019-12-30 01:48:33 +01:00
dgelessus
4e1cd05412
Fix miscellaneous mypy errors
2019-12-30 01:48:33 +01:00
dgelessus
1a416defed
Add tox configuration
2019-12-30 01:48:33 +01:00
dgelessus
1089a19c01
Add basic unit tests
2019-12-29 00:39:40 +01:00
dgelessus
8fc24040ea
Add resource-info subcommand
2019-12-26 01:58:23 +01:00