Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add context manager to Reader and other improvements #122

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

Merged
merged 6 commits into from
Jun 6, 2018

Conversation

megies
Copy link
Contributor

@megies megies commented Oct 15, 2017

Hi there, this PR proposes to add a context manager that makes sure open files are closed properly in the most Pythonic way there is (also see #107).

I've also made some other improvements (at least I think they are ;-), these can be singled out if you don't agree with all of them:

  • derive all classes from object (i.e. make them new style classes)
  • add convenience mapping "shapeType number" <---> "shapeType string" (keeping old module attributes like shapefile.POINT)
  • improve closing of individual pieces dbf/shp/shx, I think it's not safe right now, if one of these fails, the rest of them are not closed by Reader.close()

I've just started using pyshp for shapefile manipulations, thanks for the project! It's so convenient that it's noarch, pure Python and py2/3! ❤️

Eventually tests should really be implemented as unit tests, which is not a lot of work when relying on pytest, and Travis (ah Travis is set up already) and Appveyor should be set up as CI. I don't have time for this right now but might make a PR for this in the future..

Fixes #121

@karimbahgat
Copy link
Collaborator

Very useful, should make file handling more stable. Thanks 👍

@megies megies deleted the context_manager branch June 7, 2018 08:13
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.

WindowsError: The process cannot access the file because it is being used by another process
2 participants