Refactor epsgRef to use JSON file in platform independent location#422
Merged
Conversation
Contributor
|
@mwtoews Since appdirs is not a standard python package can you wrap the import in a try and except. If it fails an import exception should probably be issued. You should also add this dependency to the optional method dependencies. Feel free to improve the docstrings on the epsgRef! |
Replace previous logic for epsgref.py as a database with a similar JSON structure. New storage location is platform independent, located using appdirs package (if available), otherwise in 'HOME/.flopy'
Contributor
Author
|
Thanks @jdhughes-usgs , those are reasonable suggestions. I've set the fall-back location in 'HOME/.flopy' if appdirs is not available. (Btw, I see 'appdirs' bundled in with Anaconda, but not with Miniconda). I was considering adding 'appdirs' as a dependency to the optional methods dependencies section, however it's not so simple to map this dependency out to particular functions. It's also not a vital dependency either. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous implementation stored user data within a Python module in a platform specific location, which is problematic on many levels.
For instance, on platforms that don't use
site-packges, this is the error:Furthermore, often this directory is not user-writable, therefore many of the tricks to read/write epsgref.py would not work without root privileges. And there are too many workarounds required to make a Python module behave as hashable and human-readable database (e.g. reload(), deleting .pyc, etc.).
I think it's better to store the user data using appdirs, which effortlessly finds the platform independent and writable user data directory. Furthermore, use a JSON to store the EPSG coordinate reference system data. This PR uses an OrderedDict to maintain the insertion order, in case it helps to inspect any issues.
While re-doing parts of the Notebook, I noticed that "junk" gets stored with this PR, but it seems this should have been the case with the previous implementation too.