-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfiles.py
More file actions
29 lines (21 loc) · 767 Bytes
/
files.py
File metadata and controls
29 lines (21 loc) · 767 Bytes
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
import pathlib
import json
def get_temp_file_path():
path = pathlib.Path.home().as_posix() + '/.cache/pyrp360'
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
return path + '/tmp_current_preset.rp360p'
class Configuration:
def __init__(self):
self.file_path = 'config.json' #pathlib.Path.home().as_posix() + '/.config/pyrp360/config.json'
self.data = None
with open(self.file_path, 'r') as f:
self.data = json.load(f)
f.close()
def write(self, key, value):
self.data.update({key: value})
j = json.JSONEncoder()
with open(self.file_path, 'w') as f:
f.write(j.encode(self.data))
f.close()
def get(self, key):
return self.data.get(key)