-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
84 lines (57 loc) · 1.99 KB
/
app.py
File metadata and controls
84 lines (57 loc) · 1.99 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from os import system, name
from forex_python.converter import CurrencyCodes
from src.AutoWise import AutoWise
def main():
clear()
print("============== Welcome to AutoWise ==============\n\n")
auto_wise = AutoWise()
source_currency, target_currency = prompt_currencies()
try:
auto_wise.set_currencies(source_currency, target_currency)
auto_wise.set_profile_id()
clear()
auto_wise.setup()
clear()
auto_wise.start()
except KeyboardInterrupt:
pass
except Exception as e:
print(e)
finally:
input("\n\nPress enter to finish.")
def prompt_currencies():
is_source_currency_valid = False
is_target_currency_valid = False
while not is_source_currency_valid or not is_target_currency_valid:
# Get source currency
if not is_source_currency_valid:
source_currency = input(
f"Source currency code (FROM)? (e.g. CAD) ").upper()
if check_currency_code(source_currency):
is_source_currency_valid = True
# Get target currency
if not is_target_currency_valid and is_source_currency_valid:
target_currency = input(
f"Target currency code (TO)? (e.g. USD) ").upper()
if check_currency_code(target_currency):
is_target_currency_valid = True
if not is_source_currency_valid or not is_target_currency_valid:
print("Invalid currency code\n")
elif source_currency == target_currency:
print("Source and target currency cannot be the same\n")
return source_currency, target_currency
def check_currency_code(currency_code):
c = CurrencyCodes()
if c.get_currency_name(currency_code) is None:
return False
return True
# Clear the terminal
def clear():
# If windows
if name == "nt":
system('cls')
# If mac
else:
system('clear')
if __name__ == '__main__':
main()