-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_activity.py
48 lines (40 loc) · 1.14 KB
/
remove_activity.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
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
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()
database=open_file()
reference = database.copy()
# del reference['timestamp']
# del database['timestamp']
next_key = next(iter(reversed(sorted(reference))))
print("Removing: ",next_key)
del database[next_key]
del reference[next_key]
remaining_key = next(iter(reversed(sorted(reference))))
print("Remaining Key: ",remaining_key)
close_file(database)