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

Support for opening pathlib.Path #170

Closed
clintval opened this issue Feb 4, 2018 · 4 comments · Fixed by #175
Closed

Support for opening pathlib.Path #170

clintval opened this issue Feb 4, 2018 · 4 comments · Fixed by #175

Comments

@clintval
Copy link
Contributor

clintval commented Feb 4, 2018

Would you be willing include support for the standard library Path object?

>>> from pathlib import Path
>>> from smart_open import smart_open

>>> path = Path('~/test.txt').expand_user().resolve()
>>> smart_open(path)

TypeError: don't know how to handle uri PosixPath('/home/user/test.txt')

I would be willing to create the PR! Thanks!

@mpenkov
Copy link
Collaborator

mpenkov commented Feb 4, 2018 via email

@clintval
Copy link
Contributor Author

clintval commented Feb 4, 2018

No benefit except for duck-typing.

If parity with open() is a goal of this project than it would make sense for it be supported. No worries if not!

@mpenkov
Copy link
Collaborator

mpenkov commented Feb 4, 2018 via email

@menshikh-iv
Copy link
Contributor

@mpenkov sounds simple, I agree with @clintval position (if we "mimic" to open - we should add this).

menshikh-iv pushed a commit that referenced this issue Mar 22, 2018
* Support opening pathlib.Path

* Edited opening pathlib.Path test which skips if not available

* Added pathlib2 backport support including tests

* Added pathlib2 to test_require for supporting pathlib backport

* Fix author/maintainer fields in `setup.py`, avoid bug from `setuptools==39.0.0`. Fix #176 (#178)

* fix author/maintainer fields

* attemp to resolve problem with botocore

* try other workaround for botocore

* next attemp

* bump version to 1.5.7

* bump changelos to 1.5.7

* Reduced code logic redundancy in pathlib.Path test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants