break stuff by adding new param

This commit is contained in:
Pablo Martin 2024-06-12 17:36:33 +02:00
parent 013f2cdadb
commit 78e3d71b05
4 changed files with 34 additions and 3 deletions

View file

@ -5,7 +5,7 @@ from typing import Union
from money.currency import Currency
from xexe.constants import DEFAULT_CURRENCIES
from xexe.constants import DEFAULT_CURRENCIES, RATES_SOURCES
from xexe.utils import DateRange
logger = logging.getLogger()
@ -16,6 +16,7 @@ def handle_get_rates_inputs(
end_date: Union[datetime.datetime, datetime.date],
currencies: Union[None, str],
dry_run: bool,
rates_source: str,
ignore_warnings: bool,
output: Union[str, pathlib.Path],
):
@ -36,6 +37,9 @@ def handle_get_rates_inputs(
logger.info("No currency list passed. Running for default currencies.")
currencies = DEFAULT_CURRENCIES
if rates_source not in RATES_SOURCES:
raise ValueError(f"--rates-source must be one of {RATES_SOURCES.keys()}.")
# The Path constructor is idempotent, so this works equally fine if output
# is a string or an actual Path object.
output = pathlib.Path(output)
@ -46,6 +50,7 @@ def handle_get_rates_inputs(
"date_range": date_range,
"currencies": currencies,
"dry_run": dry_run,
"rates_source": rates_source,
"ignore_warnings": ignore_warnings,
"output": output,
}