Skip to content

Commit

Permalink
Loading the config file from parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed Mar 16, 2024
1 parent 263426c commit 4d5f9de
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions podcast_downloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def build_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--config",
required=False,
type=open,
type=str,
help="The path to configuration file",
)

Expand Down Expand Up @@ -170,13 +170,20 @@ def configuration_to_function_rss_to_name(
configuration.CONFIG_PODCASTS: [],
}

CONFIG_FILE = "~/.podcast_downloader_config.json"
logger.info('Loading configuration (from file: "%s")', CONFIG_FILE)
PARAMETERS_CONFIGURATION = parse_argv(build_parser())

config_file_name = PARAMETERS_CONFIGURATION.get(
"config", "~/.podcast_downloader_config.json"
)
logger.info('Loading configuration (from file: "%s")', config_file_name)
CONFIGURATION_FROM_FILE = load_configuration_file(
os.path.expanduser(config_file_name)
)

CONFIGURATION = merge_parameters_collection(
DEFAULT_CONFIGURATION,
load_configuration_file(os.path.expanduser(CONFIG_FILE)),
parse_argv(build_parser()),
CONFIGURATION_FROM_FILE,
PARAMETERS_CONFIGURATION,
)

is_valid, error = configuration_verification(CONFIGURATION)
Expand Down

0 comments on commit 4d5f9de

Please sign in to comment.