... |
... |
@@ -18,15 +18,13 @@ CURRENCIES = {
|
18 |
18 |
}
|
19 |
19 |
|
20 |
20 |
def main():
|
21 |
|
- table = get_table()
|
22 |
21 |
filepath = sys.argv[1]
|
23 |
22 |
history = get_history(filepath)
|
|
23 |
+ timestamp = history.get('timestamp', time.time())
|
|
24 |
+ table = get_table(timestamp)
|
24 |
25 |
for operation in history.get('data', []):
|
25 |
26 |
add_operation(table, operation)
|
26 |
27 |
print(table)
|
27 |
|
- timestamp = history.get('timestamp', time.time())
|
28 |
|
- timestamp = format_timestamp_colored(timestamp, MAX_AGE)
|
29 |
|
- print('Data cached on %s' % timestamp)
|
30 |
28 |
|
31 |
29 |
def get_history(history_json_path):
|
32 |
30 |
if history_json_path == '-':
|
... |
... |
@@ -35,10 +33,13 @@ def get_history(history_json_path):
|
35 |
33 |
with open(history_json_path, 'r') as filedesc:
|
36 |
34 |
return json.load(filedesc)
|
37 |
35 |
|
38 |
|
-def get_table():
|
|
36 |
+def get_table(timestamp):
|
39 |
37 |
pt = PrettyTable()
|
40 |
|
- pt.field_names = ['Date', 'Label', 'Amount']
|
41 |
|
- pt.field_names = [colored(x, 'white', attrs=['bold']) for x in pt.field_names]
|
|
38 |
+ field_names = ['Date', 'Label', 'Amount']
|
|
39 |
+ field_names = [colored(x, 'white', attrs=['bold']) for x in field_names]
|
|
40 |
+ timestamp = format_timestamp_colored(timestamp, MAX_AGE)
|
|
41 |
+ field_names[1] += ' -- data cached on %s' % timestamp
|
|
42 |
+ pt.field_names = field_names
|
42 |
43 |
pt.align = 'l'
|
43 |
44 |
pt.align[pt.field_names[2]] = 'r'
|
44 |
45 |
return pt
|