Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Sep 2, 2024
2 parents 7ead7bf + 1eb34ee commit 49e5603
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions premise/filesystem_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@
from pathlib import Path

import platformdirs
import yaml


def load_var_file():
"""Check if the variable file exists and load it."""
var_file = Path.cwd() / "variables.yaml"
if var_file.exists():
with open(var_file, "r") as f:
return yaml.safe_load(f)
else:
return None


VARIABLES = load_var_file() or {}

# Directories for data which comes with Premise
DATA_DIR = Path(__file__).resolve().parent / "data"
INVENTORY_DIR = DATA_DIR / "additional_inventories"
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")
if "USER_DATA_BASE_DIR" in VARIABLES:
USER_DATA_BASE_DIR = Path(VARIABLES.get("USER_DATA_BASE_DIR"))
print(f"USER_DATA_BASE_DIR: {USER_DATA_BASE_DIR}")
else:
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"
Expand Down

0 comments on commit 49e5603

Please sign in to comment.