changed json format to exclude redundant information
Signed-off-by: Konrad <klux2@hs-mittweida.de>
This commit is contained in:
parent
9e0622e985
commit
2fd4dab43f
1 changed files with 8 additions and 12 deletions
|
@ -63,7 +63,7 @@ botID = -1
|
||||||
class EnumEncode(json.JSONEncoder):
|
class EnumEncode(json.JSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
if type(obj) is Language:
|
if type(obj) is Language:
|
||||||
return {"Language": str(obj.name)}
|
return str(obj.name)
|
||||||
return json.JSONEncoder.default(self, obj)
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,17 +367,13 @@ def get_now() -> str:
|
||||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
def process_json(d: dict) -> Any:
|
def process_json(d):
|
||||||
if "Language" in d:
|
if isinstance(d, dict):
|
||||||
lang = d["Language"]
|
try:
|
||||||
return getattr(Language, lang)
|
return {int(k): getattr(Language, v) for k, v in d.items()}
|
||||||
else:
|
except (ValueError, TypeError):
|
||||||
if isinstance(d, dict):
|
return d
|
||||||
try:
|
return d
|
||||||
return {int(k): v for k, v in d.items()}
|
|
||||||
except ValueError:
|
|
||||||
return d
|
|
||||||
return d
|
|
||||||
|
|
||||||
|
|
||||||
sys.stdout = open("out.log", "a")
|
sys.stdout = open("out.log", "a")
|
||||||
|
|
Loading…
Reference in a new issue