-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoney.py
executable file
·51 lines (37 loc) · 1.37 KB
/
money.py
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
#!/bin/env python3
# -*- coding: utf-8 -*
import sys, list, converter, settings
if __name__ == '__main__' :
nargs = len(sys.argv)
if ( nargs == 1 ) :
tocheck = settings.settings['tocheck']
for cFrom in tocheck :
for cTo in tocheck[ cFrom ] :
cc = converter.convert(cFrom, cTo)
print('1', cFrom, '=', cc, cTo)
print() # Print an empty line
print('\nPass -h as agrument to see the help')
if ( nargs == 2 ) :
if sys.argv[1] == '-h' :
print('HELP') # TODO : Write help
elif sys.argv[1] == 'list' :
curr = list.list_currencies()
for k in curr:
print(k, '-', curr[k])
else :
print('ERROR : The argument passed is not recognised')
if ( nargs == 3 ) :
# TODO : Check if the two currencies exists
if True :
val = converter.convert(sys.argv[1], sys.argv[2])
print('1', sys.argv[1], '=', val, sys.argv[2])
if ( nargs == 4 ) :
# TODO : Check all the parameters
if True :
amount = sys.argv[1]
from_ = sys.argv[2]
to = sys.argv[3]
val = converter.convert(from_, to, amount)
print(amount, from_, '=', val, to)
if ( nargs > 4 ) :
print('ERROR : Too many arguments.\nPass -h as argumnet to see the help')