mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-15 10:22:26 +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)
|
||||
|
||||
|
||||
def load(string, fromString=False):
|
||||
def load(string, fromString=False, protocol=None):
|
||||
"""Load settings from 'string'. 'string' is the filename of the pickle dump.
|
||||
If fromString=True, string is the data of the pickle dumps."""
|
||||
global allSettings
|
||||
|
@ -145,8 +145,11 @@ def load(string, fromString=False):
|
|||
print("{} doesn't exist, cannot load settings.".format(string))
|
||||
return
|
||||
else:
|
||||
allSettings = pickle.loads(string)
|
||||
|
||||
if protocol == 0:
|
||||
allSettings = json.loads(string)
|
||||
else:
|
||||
allSettings = pickle.loads(string)
|
||||
|
||||
#pp=pprint.PrettyPrinter(indent=4, compact=False)
|
||||
#print("Loading:")
|
||||
#pp.pprint(allSettings)
|
||||
|
@ -223,6 +226,17 @@ def load(string, fromString=False):
|
|||
global 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:
|
||||
global frequencyAnalyzer
|
||||
frequencyAnalyzer = allSettings["frequencyAnalyzer"]
|
||||
|
|
Loading…
Reference in a new issue