pulled up, fixed tests
This commit is contained in:
parent
a7a37d4614
commit
7f8001ffca
3 changed files with 26 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import datetime
|
||||
import logging
|
||||
import pathlib
|
||||
from itertools import combinations
|
||||
from typing import Union
|
||||
|
||||
from money.currency import Currency
|
||||
|
|
@ -29,6 +30,10 @@ def handle_get_rates_inputs(
|
|||
if date_range.end_date > datetime.datetime.today().date():
|
||||
date_range.end_date = datetime.datetime.today().date()
|
||||
|
||||
if (currencies is None or currencies == "") and not pairs:
|
||||
logger.info("No currency list or pairs passed. Running for default currencies.")
|
||||
currencies = DEFAULT_CURRENCIES
|
||||
|
||||
if pairs:
|
||||
if currencies:
|
||||
logger.error(f"Received both currencies and pairs.")
|
||||
|
|
@ -47,12 +52,11 @@ def handle_get_rates_inputs(
|
|||
if currencies:
|
||||
# CLI input comes as a string of comma-separated currency codes
|
||||
currencies = {currency_code.strip() for currency_code in currencies.split(",")}
|
||||
tmp = {Currency(currency_code) for currency_code in currencies}
|
||||
currencies = tmp
|
||||
|
||||
if currencies is None or currencies == "" and not pairs:
|
||||
logger.info("No currency list or pairs passed. Running for default currencies.")
|
||||
currencies = DEFAULT_CURRENCIES
|
||||
currencies = {Currency(currency_code) for currency_code in currencies}
|
||||
pairs = list(combinations(currencies, 2))
|
||||
pairs = {
|
||||
CurrencyPair(from_currency=pair[0], to_currency=pair[1]) for pair in pairs
|
||||
}
|
||||
|
||||
if rates_source not in RATES_SOURCES:
|
||||
raise ValueError(f"--rates-source must be one of {RATES_SOURCES.keys()}.")
|
||||
|
|
@ -72,9 +76,6 @@ def handle_get_rates_inputs(
|
|||
"output": output,
|
||||
}
|
||||
|
||||
if currencies:
|
||||
prepared_inputs["currencies"] = currencies
|
||||
|
||||
if pairs:
|
||||
prepared_inputs["pairs"] = pairs
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
from itertools import combinations
|
||||
from typing import List, Set, Union
|
||||
|
||||
from money.currency import Currency
|
||||
|
|
@ -73,19 +72,12 @@ def run_get_rates(
|
|||
rates_source: str,
|
||||
ignore_warnings: bool,
|
||||
output: pathlib.Path,
|
||||
currencies: Union[Set[Currency], None] = None,
|
||||
pairs: Union[Set[CurrencyPair], None] = None,
|
||||
) -> None:
|
||||
logger.info("Getting rates")
|
||||
|
||||
process_state = GetRatesProcessState(ignore_warnings=ignore_warnings)
|
||||
|
||||
if currencies:
|
||||
pairs = list(combinations(currencies, 2))
|
||||
pairs = [
|
||||
CurrencyPair(from_currency=pair[0], to_currency=pair[1]) for pair in pairs
|
||||
]
|
||||
|
||||
currency_and_date_combinations = generate_pairs_and_dates_combinations(
|
||||
date_range=date_range, pairs=pairs
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue