More explicit errors

This commit is contained in:
Christopher Teutsch 2019-05-03 23:28:20 +02:00
parent 6afbc59ef4
commit e2f67fa552
Signed by: iwonder
GPG Key ID: 0EE33D788D50130D

View File

@ -79,20 +79,24 @@ def _process_stdin(argv: str, res: utils.CurrencyResult) -> None:
sys.exit() sys.exit()
elif argv[0] in ['date', 'd']: elif argv[0] in ['date', 'd']:
print(res.date) print(res.date)
elif is_float(argv[0]): elif len(argv[0])==3 or len(argv[1])==3:
# amount first -> convert to currency in argv[1] # more than 3 letter abbreviations are invalid
print(fmt_and_calc( if is_float(argv[0]):
cur=argv[1].upper(), # amount first -> convert to currency in argv[1]
amt=float(argv[0]), print(fmt_and_calc(
res=res, cur=argv[1].upper(),
direction=DIRECTION_FROM_EUR)) amt=float(argv[0]),
elif is_float(argv[1]): res=res,
# currency first -> convert to EUR direction=DIRECTION_FROM_EUR))
print(fmt_and_calc( elif is_float(argv[1]):
cur=argv[0].upper(), # currency first -> convert to EUR
amt=float(argv[1]), print(fmt_and_calc(
res=res, cur=argv[0].upper(),
direction=DIRECTION_TO_EUR)) amt=float(argv[1]),
res=res,
direction=DIRECTION_TO_EUR))
else:
print("Not implemented: '" + " ".join(argv) + "'")
except IndexError: except IndexError:
if argv is None: if argv is None:
pass pass