-
Notifications
You must be signed in to change notification settings - Fork 51
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
Refactor user data directories with platformdirs
#122
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
131119b
Refactor user data directories with platformdirs
cmutel 7631756
Black reformating
romainsacchi b2c57c6
Remove unused imports
cmutel d6fa5e3
Fix import statement
cmutel 68e3e05
Add tests for filesystem constants
cmutel 08fb1ca
Black reformating
romainsacchi c161b2f
Add missing dependency
cmutel b4e2361
Merge branch 'platformdirs' of https://github.com/cmutel/rmnd-lca int…
cmutel c355b28
Some people are not Romain :tongue:
cmutel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
__all__ = ("NewDatabase", "clear_cache", "get_regions_definition") | ||
__version__ = (1, 7, 6) | ||
|
||
from pathlib import Path | ||
|
||
DATA_DIR = Path(__file__).resolve().parent / "data" | ||
INVENTORY_DIR = Path(__file__).resolve().parent / "data" / "additional_inventories" | ||
VARIABLES_DIR = Path(__file__).resolve().parent / "iam_variables_mapping" | ||
|
||
from .ecoinvent_modification import NewDatabase | ||
from .utils import clear_cache, get_regions_definition |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pathlib import Path | ||
|
||
import platformdirs | ||
|
||
# Directories for data which comes with Premise | ||
DATA_DIR = Path(__file__).resolve().parent / "data" | ||
INVENTORY_DIR = DATA_DIR / "additional_inventories" | ||
# Todo: Should this be in the data directory? | ||
VARIABLES_DIR = Path(__file__).resolve().parent / "iam_variables_mapping" | ||
IAM_OUTPUT_DIR = DATA_DIR / "iam_output_files" | ||
|
||
# Directories for user-created data | ||
USER_DATA_BASE_DIR = platformdirs.user_data_path(appname="premise", appauthor="pylca") | ||
USER_DATA_BASE_DIR.mkdir(parents=True, exist_ok=True) | ||
|
||
DIR_CACHED_DB = USER_DATA_BASE_DIR / "cache" | ||
DIR_CACHED_DB.mkdir(parents=True, exist_ok=True) | ||
|
||
USER_LOGS_DIR = platformdirs.user_log_path(appname="premise", appauthor="pylca") | ||
USER_LOGS_DIR.mkdir(parents=True, exist_ok=True) |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moves the DATA_DIR related vars to the new filesystem_constants module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed all the internal imports, and these paths were in
__all__
so shouldn't be importable in any case?