historical: Write results to cache when appropriate.
This commit is contained in:
parent
7ae8c359e0
commit
3b5a563ef6
2 changed files with 5 additions and 0 deletions
|
@ -12,6 +12,8 @@ def run(config, stdout, stderr):
|
|||
loaders = config.get_loaders()
|
||||
with loaders.historical(config.args.date, config.args.base) as rate_json:
|
||||
rate = oxrrate.Rate.from_json_file(rate_json)
|
||||
if loaders.should_cache():
|
||||
config.cache.save_rate(rate)
|
||||
if not config.args.from_currency:
|
||||
for from_curr in sorted(rate.rates):
|
||||
print(*format_rate_pair(rate, from_curr, config.args.to_currency),
|
||||
|
|
|
@ -19,6 +19,9 @@ class FakeResponder:
|
|||
def __getattr__(self, name):
|
||||
return self._respond
|
||||
|
||||
def should_cache(self):
|
||||
return False
|
||||
|
||||
|
||||
class FakeConfig:
|
||||
def __init__(self, responder, argvars=None):
|
||||
|
|
Loading…
Reference in a new issue