Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce writef() and writestr() method #293

Merged
merged 8 commits into from Feb 12, 2021
Merged

Introduce writef() and writestr() method #293

merged 8 commits into from Feb 12, 2021

Conversation

miurahr
Copy link
Owner

@miurahr miurahr commented Feb 6, 2021

Implement a feature request #248 and #290

  • writestr(str_or_bytes, arcname: str) accept str or bytes family data for compression.
    when receiving str as argument, it encode it into UTF-8
  • writef(BytesIO_or_binary_fileobject, arcname: str) accept io.BytesIO() memory buffer or file object with open(mode='rb')

Signed-off-by: Hiroshi Miura miurahr@linux.com

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@miurahr miurahr added the enhancement New feature or request label Feb 6, 2021
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@coveralls
Copy link

coveralls commented Feb 6, 2021

Coverage Status

Coverage increased (+0.06%) to 90.034% when pulling 0518c80 on topic-writestr into 41c2ff8 on master.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
- convert to UTF-8 encoding

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@miurahr miurahr changed the title Very primitive implementation of writestr() method Introduce writef() and writestr() method Feb 7, 2021
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
accept object which as read() and length methods(__len__() or __sizeof__())

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
accept object which as read() and length methods(__sizeof__())
which is compatible with BinaryIO.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
pypy3's BufferedReader don't have __sizeof__()
so alternatively calculate it with seek() and tell()

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@miurahr miurahr merged commit a01865f into master Feb 12, 2021
@miurahr miurahr deleted the topic-writestr branch February 18, 2021 03:21
@hildogjr
Copy link

hildogjr commented Feb 18, 2021

Just following up this merge-request. Two question:

  1. When this will be on PyPI?
  2. Should we change the order of the input parameters to better match with zipfile Python library? As discussion on writestr support just like ZipFile.writestr #290 we have ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None) on this implementation was used def writestr(self, data: Union[bytes, bytearray, memoryview], arcname: str) (the opposite order, it is the same case with tarfile Python module).

miurahr added a commit that referenced this pull request Feb 18, 2021
Added
-----

* Add writestr() and writef() methods in SevenZipFile class.(#290,#293)
* Add benchmark tests for compression algorithms(#295)
* Track benchmark results on Github issue(#296)

Changed
-------

* Refactoring BCF Filter classes, and move to individual module.(#292)

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants