Ensures the configuration directory (~/.config/pure_recipe) is created if it does not exist, using os.makedirs with exist_ok=True.
Changes the working directory to the configuration directory, providing a consistent location for config.yaml.
Improves the portability of the script by setting a unified configuration path that works seamlessly on different OS environments.
Configuration File Initialization:
Automatically generates config.yaml in the configuration directory with default values if the file is missing.
Default values set for directory, time, and yield fields ensure that the configuration file always contains the necessary keys, reducing the chance of errors due to missing configuration settings.
Enhanced Configuration Loading and Default Fallbacks:
Loads settings from config.yaml using yaml.safe_load(), ensuring safe parsing of the YAML content.
Checks for empty or missing fields in config.yaml and initializes settings with default values where needed: directory: Defaults to ~/Documents/recipes if not specified.
time and yield: Default values are set to "true" and "m", respectively, to avoid issues with missing or blank entries.
Recipe Directory Creation:
The script sets recipe_directory from settings.get("directory"). If the directory path is missing or invalid, it defaults to a user-friendly location (~/Documents/pure_recipes).
Creates the recipe_directory if it doesn’t exist, ensuring a designated space for saving recipes and enhancing the out-of-the-box experience.
Error Prevention and Improved Defaults:
Uses settings.setdefault() to set defaults for time and yield fields only if they are missing or empty in config.yaml.
This structure makes the script more resilient by preventing NoneType errors when accessing configuration values.
Improves compatibility across different environments, as users no longer need to manually ensure config.yaml or recipe_directory exist.
Resolves #19
Configuration Directory Management:
Configuration File Initialization:
Enhanced Configuration Loading and Default Fallbacks:
Recipe Directory Creation:
Error Prevention and Improved Defaults: