This repository was archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
44 lines (35 loc) · 1.33 KB
/
config.py
File metadata and controls
44 lines (35 loc) · 1.33 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
import os
import json
class Config:
def __init__(self, working_dir):
self.searchTags = ["animal_ears"]
self.width = "1920"
self.height = "1080"
self.rating = "safe"
self.removeOld = True
if os.path.exists(os.path.join(working_dir, "config.json")):
with open(os.path.join(working_dir, "config.json")) as file:
self.__dict__ = json.load(file)
else:
with open(os.path.join(working_dir, "config.json"), 'w') as file:
json.dump(self.__dict__, file, indent=4)
def toJSON(self):
return json.dumps(self, default=lambda a: a.__dict__, sort_keys=False, indent=4)
def saveConfig(self, working_dir):
if not os.path.exists(os.path.join(working_dir, "config.json")):
with open(os.path.join(working_dir, "config.json"), 'w') as file:
json.dump(self.__dict__, file, indent=4)
def getSearchTags(self):
return self.searchTags
def getDimensions(self):
return (self.width, self.height)
def getDimension(self, dimension):
if dimension == "width":
return self.width
elif dimension == "height":
return self.height
return None
def getRating(self):
return self.rating
def getRemoveOld(self):
return self.removeOld