-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrency_convert.py
More file actions
executable file
·26 lines (18 loc) · 967 Bytes
/
currency_convert.py
File metadata and controls
executable file
·26 lines (18 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
import argparse
from src.currency_converter import CurrencyConverter
def main():
converter = CurrencyConverter()
parser = argparse.ArgumentParser(description='Currency converter')
parser.add_argument('--amount', type=int, required=True, help="Amount which we want to convert")
parser.add_argument('--input_currency', required=True,
help="Input currency in format of 3 letters symbol eg.(EUR)")
parser.add_argument('--output_currency', default=None,
help="Output currency in format of 3 letters symbol eg.(USD)")
args = parser.parse_args()
from_currency, to_currency = converter.symbol_to_currency(args.input_currency, args.output_currency)
converted_dict = converter.convert(args.amount, from_currency, to_currency)
output = converter.output_formatter(args.amount, from_currency, converted_dict)
print(output)
if __name__ == "__main__":
main()