-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_notables.py
64 lines (56 loc) · 1.68 KB
/
update_notables.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
52
53
54
55
56
57
58
59
60
61
62
63
64
import requests
import time
import datetime
from datetime import date
import json
import calendar
import credentials
import pprint
import renew
from pathlib import Path
import pickle
import data
dictionary_file = Path('./running_data.dict')
def open_file():
if dictionary_file.is_file():
pickle_in = open(dictionary_file,"rb")
sav_dict = pickle.load(pickle_in)
print("Found saved dictionary")
else:
f=open(dictionary_file,"w+") #create file
f.close()
print("Creating new dictionary file")
sav_dict = {}
#sav_dict['timestamp'] = datetime.datetime(1900, 1, 1)
return sav_dict
def close_file(sav_dict):
#sav_dict['timestamp'] = datetime.datetime.now()
outfile = open(dictionary_file,"wb")
pickle.dump(sav_dict, outfile)
outfile.close()
run = 1
database=open_file()
for x in reversed(sorted(database)):
print(x)
print("Run: ",str(run))
run = run + 1
if database[x]['smash'] != "N/A":
if 'notables' in database[x]['smash']: # pass if entry exists
print("Already have notables for this run")
pass
else:
print(database[x]['smash']['activityId'])
notables = data.smash_notables(database[x]['smash']['activityId'])
print(notables)
if notables:
database[x]['smash']['notables'] = notables
close_file(database)
else:
print("No notables for this time period")
database[x]['smash']['notables'] = 'N/A'
print('***')
# next_key = next(iter(database))
#
# pprint.pprint(database[next_key])
# print(next_key)
# print(database[next_key]['weekday_full_date'])