-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcache.py
More file actions
48 lines (32 loc) · 1.14 KB
/
Copy pathcache.py
File metadata and controls
48 lines (32 loc) · 1.14 KB
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 os
import json
def get_cache_dir():
if os.name == "nt":
base = os.path.join(os.environ.get("APPDATA", os.path.expanduser("~")),
"GameSupportTracker")
else:
base = os.path.join(os.path.expanduser("~"), ".config", "GameSupportTracker")
os.makedirs(base, exist_ok=True)
return base
def get_cache_path():
return os.path.join(get_cache_dir(), "archipelago_cache.json")
def get_settings_path():
return os.path.join(get_cache_dir(), "settings.json")
CACHE_FILE = get_cache_path()
def load_cache():
if os.path.exists(CACHE_FILE):
with open(CACHE_FILE, "r", encoding="utf-8") as f:
return json.load(f)
return {}
def save_cache(data):
with open(CACHE_FILE, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
def load_settings():
p = get_settings_path()
if os.path.exists(p):
with open(p, "r", encoding="utf-8") as f:
return json.load(f)
return {}
def save_settings(data):
with open(get_settings_path(), "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)