File diff b270db02e8d7 → d0f5f1547ced
oxrlib/config.py
Show inline comments
...
 
@@ -6,6 +6,7 @@ import os.path
 
import pathlib
 

	
 
import babel
 
import babel.dates
 
import babel.numbers
 

	
 
from . import cache, loaders
...
 
@@ -74,7 +75,7 @@ class Configuration:
 
            else:
 
                retval -= datetime.timedelta(days=replacements['day'])
 
                retval = retval.replace(**replacements)
 
        return retval
 
        return retval, replacements
 

	
 
    def _build_argparser(self):
 
        prog_parser = argparse.ArgumentParser()
...
 
@@ -191,6 +192,7 @@ class Configuration:
 
            return default
 

	
 
    def _post_hook_historical(self):
 
        self.args.date, date_spec = self.args.date
 
        year = self.args.date.year
 
        if year < 100:
 
            # Don't let the user specify ambiguous dates.
...
 
@@ -223,6 +225,18 @@ class Configuration:
 
            self.args.to_currency = self._convert_or_error(currency_code, next_word)
 
        except StopIteration:
 
            self.args.to_currency = pref_currency
 
        if ((len(date_spec) == 1)
 
            and self.args.from_currency
 
            and (self.args.amount is None)):
 
            self.error(("ambiguous input: "
 
                        "Did you want rates for {args.from_currency} on {date}, "
 
                        "or to convert {amt} {args.from_currency} to {args.to_currency}?\n"
 
                        "Specify more of the date to disambiguate."
 
                        ).format(
 
                            args=self.args,
 
                            date=babel.dates.format_date(self.args.date),
 
                            amt=date_spec['day'],
 
                        ))
 

	
 
    def _build_cache_loader(self):
 
        kwargs = dict(self.conffile.items('Cache'))