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

New feature: introduce compressor registry #266

Merged
merged 2 commits into from
Mar 9, 2019
Merged

New feature: introduce compressor registry #266

merged 2 commits into from
Mar 9, 2019

Conversation

mpenkov
Copy link
Collaborator

@mpenkov mpenkov commented Feb 26, 2019

This feature makes it easy for people to transparently decode files not supported by smart_open out of the box.

For example, you can now do:

def _handle_lzma(file_obj, mode):
    import lzma
    return lzma.LZMAFile(filename=file_obj, mode=mode, format=lzma.FORMAT_ALONE)

import smart_open
smart_open.register_compressor('.lzma', _handle_lzma)
with smart_open.smart_open('file.lzma', ...) as fin:
    pass

@mpenkov mpenkov requested a review from piskvorky February 26, 2019 02:48
@mpenkov mpenkov merged commit 7b63e95 into piskvorky:master Mar 9, 2019
@mpenkov mpenkov deleted the reg branch March 9, 2019 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant