mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-10 06:54:32 +12:00
Bug corrected
This commit is contained in:
parent
22f2bd7899
commit
10fdb89eef
|
@ -131,7 +131,7 @@ def save(filename=None, protocol=None):
|
||||||
return pickle.dumps(allSettings)
|
return pickle.dumps(allSettings)
|
||||||
|
|
||||||
|
|
||||||
def load(string, fromString=False):
|
def load(string, fromString=False, protocol=None):
|
||||||
"""Load settings from 'string'. 'string' is the filename of the pickle dump.
|
"""Load settings from 'string'. 'string' is the filename of the pickle dump.
|
||||||
If fromString=True, string is the data of the pickle dumps."""
|
If fromString=True, string is the data of the pickle dumps."""
|
||||||
global allSettings
|
global allSettings
|
||||||
|
@ -145,8 +145,11 @@ def load(string, fromString=False):
|
||||||
print("{} doesn't exist, cannot load settings.".format(string))
|
print("{} doesn't exist, cannot load settings.".format(string))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
allSettings = pickle.loads(string)
|
if protocol == 0:
|
||||||
|
allSettings = json.loads(string)
|
||||||
|
else:
|
||||||
|
allSettings = pickle.loads(string)
|
||||||
|
|
||||||
#pp=pprint.PrettyPrinter(indent=4, compact=False)
|
#pp=pprint.PrettyPrinter(indent=4, compact=False)
|
||||||
#print("Loading:")
|
#print("Loading:")
|
||||||
#pp.pprint(allSettings)
|
#pp.pprint(allSettings)
|
||||||
|
@ -223,6 +226,17 @@ def load(string, fromString=False):
|
||||||
global revisions
|
global revisions
|
||||||
revisions = allSettings["revisions"]
|
revisions = allSettings["revisions"]
|
||||||
|
|
||||||
|
# With JSON we had to convert int keys to str, and None to "null", so we roll back.
|
||||||
|
r = {}
|
||||||
|
for i in revisions["rules"]:
|
||||||
|
if i == "null":
|
||||||
|
r[None] = revisions["rules"]["null"]
|
||||||
|
continue
|
||||||
|
elif i == None:
|
||||||
|
continue
|
||||||
|
r[int(i)] = revisions["rules"][i]
|
||||||
|
revisions["rules"] = r
|
||||||
|
|
||||||
if "frequencyAnalyzer" in allSettings:
|
if "frequencyAnalyzer" in allSettings:
|
||||||
global frequencyAnalyzer
|
global frequencyAnalyzer
|
||||||
frequencyAnalyzer = allSettings["frequencyAnalyzer"]
|
frequencyAnalyzer = allSettings["frequencyAnalyzer"]
|
||||||
|
|
Loading…
Reference in a new issue