Skip to content

return empty dict if config file is empty #811

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 4 commits into from
Dec 14, 2023
Merged
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
16 changes: 15 additions & 1 deletion interpreter/terminal_interface/utils/get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,25 @@ def get_config_path(path=user_config_path):
# Copying the file using shutil.copy
new_file = shutil.copy(default_config_path, path)

print("Copied the default config file to the user's directory because the user's config file was not found.")

return path


def get_config(path=user_config_path):
path = get_config_path(path)

config = None

with open(path, "r") as file:
return yaml.safe_load(file)
config = yaml.safe_load(file)
if config is not None:
return config

if config is None:
# Deleting empty file because get_config_path copies the default if file is missing
os.remove(path)
path = get_config_path(path)
with open(path, "r") as file:
config = yaml.safe_load(file)
return config