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

Supporting reading DEFAULT_RECIPE_MAP from preferences #901

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Code/autopkglib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def find_identifier_from_name(name: str) -> Optional[str]:
return None


def get_recipe_map_path() -> str:
"""Return recipe map file path from preferences or default"""
return get_pref("DEFAULT_RECIPE_MAP") or DEFAULT_RECIPE_MAP


def get_search_dirs() -> List[str]:
"""Return search dirs from preferences or default list"""
dirs: List[str] = get_pref("RECIPE_SEARCH_DIRS")
Expand Down Expand Up @@ -381,7 +386,7 @@ def write_recipe_map_to_disk():
# except (OSError):
# pass
local_recipe_map.update(globalRecipeMap)
with open(DEFAULT_RECIPE_MAP, "w") as f:
with open(get_recipe_map_path(), "w") as f:
json.dump(
local_recipe_map,
f,
Expand All @@ -394,7 +399,7 @@ def write_recipe_map_to_disk():
def handle_reading_recipe_map_file() -> Dict[str, Dict[str, str]]:
"""Read the recipe map file, handle exceptions"""
try:
with open(DEFAULT_RECIPE_MAP, "r") as f:
with open(get_recipe_map_path(), "r") as f:
recipe_map = json.load(f)
except (OSError, json.decoder.JSONDecodeError):
log_err("Cannot read the recipe map file!")
Expand Down
Loading