mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix wine
This commit is contained in:
parent
ad05ca5cf2
commit
5e2119091c
@ -1,23 +1,20 @@
|
|||||||
import json
|
import json
|
||||||
import os, time, uuid
|
import os, time, uuid, shutil
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
|
|
||||||
|
|
||||||
def tryreadconfig(path, default=None):
|
def tryreadconfig(path, default=None):
|
||||||
path = os.path.join("userconfig", path)
|
path = os.path.join("userconfig", path)
|
||||||
if not os.path.exists(path):
|
|
||||||
path += ".tmp"
|
|
||||||
dfret = default if default else {}
|
|
||||||
if not os.path.exists(path):
|
|
||||||
return dfret
|
|
||||||
try:
|
try:
|
||||||
with open(path, "r", encoding="utf-8") as ff:
|
with open(path, "r", encoding="utf-8") as ff:
|
||||||
x = json.load(ff)
|
return json.load(ff)
|
||||||
|
|
||||||
return x
|
|
||||||
except:
|
except:
|
||||||
return dfret
|
try:
|
||||||
|
with open(path + ".tmp", "r", encoding="utf-8") as ff:
|
||||||
|
return json.load(ff)
|
||||||
|
except:
|
||||||
|
return default if default else {}
|
||||||
|
|
||||||
|
|
||||||
def tryreadconfig2(path):
|
def tryreadconfig2(path):
|
||||||
@ -473,7 +470,9 @@ def safesave(fname, js, beatiful=True):
|
|||||||
ff.write(json.dumps(js, sort_keys=False))
|
ff.write(json.dumps(js, sort_keys=False))
|
||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
os.rename(fname + ".tmp", fname)
|
shutil.copy(fname + ".tmp", fname)
|
||||||
|
os.remove(fname + ".tmp")
|
||||||
|
# wine上MoveFile会权限问题失败,不知道为什么,WinError 32
|
||||||
|
|
||||||
|
|
||||||
def saveallconfig():
|
def saveallconfig():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user