-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.py
executable file
·32 lines (30 loc) · 974 Bytes
/
cleanup.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
from shutil import rmtree
from os.path import exists
import os
import pickle
from time import time
if exists("./Modern"):
rmtree("./Modern")
if exists("./Legacy"):
rmtree("./Legacy")
if exists("./Standard"):
rmtree("./Standard")
if exists("./mtggoldfish"):
rmtree("./mtggoldfish")
if exists("./mtgtop8"):
rmtree("./mtgtop8")
if not exists("./data"):
os.makedirs("./data")
if not exists("./data/temp"):
os.makedirs("./data/temp")
if exists("./data/temp"):
now = time()
for f in os.listdir("./data/temp"):
if os.stat(os.path.join("./data/temp",f)).st_mtime < now - 60 * 86400:
os.remove(os.path.join("./data/temp", f))
if exists("./data/cached_files.pkl"):
with open("./data/cached_decklists.pkl") as fp:
cached_files = pickle.load(fp)
cached_files = {k:v for k,v in cached_files.items() if exists(v)}
with open("./data/cached_decklists.pkl", "wb") as fp:
pickle.dump(cached_files, fp)