Imports were a bit optimized
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
try:
|
||||
import ujson as json
|
||||
from ujson import JSONDecodeError as JSONDecodeError
|
||||
from ujson import loads, dumps
|
||||
except ModuleNotFoundError:
|
||||
import json
|
||||
from json import JSONDecodeError as JSONDecodeError
|
||||
from json import loads, dumps
|
||||
|
||||
import os
|
||||
import sys
|
||||
@@ -16,7 +16,7 @@ def jsonLoad(filename):
|
||||
"""Loads arg1 as json and returns its contents"""
|
||||
with open(filename, "r", encoding='utf8') as file:
|
||||
try:
|
||||
output = json.loads(file.read())
|
||||
output = loads(file.read())
|
||||
except JSONDecodeError:
|
||||
logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{traceback.print_exc()}")
|
||||
raise
|
||||
@@ -30,7 +30,7 @@ def jsonSave(contents, filename):
|
||||
"""Dumps dict/list arg1 to file arg2"""
|
||||
try:
|
||||
with open(filename, "w", encoding='utf8') as file:
|
||||
file.write(json.dumps(contents, ensure_ascii=False, indent=4))
|
||||
file.write(dumps(contents, ensure_ascii=False, indent=4))
|
||||
file.close()
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not save json file {filename}: {exp}\n{traceback.print_exc()}")
|
||||
|
Reference in New Issue
Block a user