Changeset - f9c045a63efc
[Not reviewed]
0 1 0
Brett Smith - 7 years ago 2017-05-17 16:36:04
brettcsmith@brettcsmith.org
historical: Switch to relative import.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
oxrlib/commands/historical.py
Show inline comments
 
import oxrlib.rate
 
from .. import rate as oxrrate
 

	
 
def format_one_rate(rate, from_amt, from_curr, to_curr):
 
    return "{:g} {} = {:g} {}".format(
 
        from_amt, from_curr, rate.convert(from_amt, from_curr, to_curr), to_curr)
 

	
 
def format_rate_pair(rate, from_curr, to_curr):
 
    yield format_one_rate(rate, 1, from_curr, to_curr)
 
    yield format_one_rate(rate, 1, to_curr, from_curr)
 

	
 
def run(config, stdout, stderr):
 
    loaders = config.get_loaders()
 
    with loaders.historical(config.args.date, config.args.base) as rate_json:
 
        rate = oxrlib.rate.Rate.from_json_file(rate_json)
 
        rate = oxrrate.Rate.from_json_file(rate_json)
 
    if not config.args.from_currency:
 
        for from_curr in sorted(rate.rates):
 
            print(*format_rate_pair(rate, from_curr, config.args.to_currency),
 
                  sep='\n', file=stdout)
 
    elif config.args.amount is None:
 
        print(*format_rate_pair(rate, config.args.from_currency, config.args.to_currency),
0 comments (0 inline, 0 general)