mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-03 11:34:33 +12:00
Saves revision even in non-zip format
This commit is contained in:
parent
fc89207ca8
commit
ed7e5f69b5
|
@ -15,7 +15,7 @@ def saveProject(version=None):
|
||||||
if version == 0:
|
if version == 0:
|
||||||
v0.saveProject()
|
v0.saveProject()
|
||||||
else:
|
else:
|
||||||
v1.saveProject()
|
v1.saveProject(zip=True)
|
||||||
|
|
||||||
|
|
||||||
def loadProject(project):
|
def loadProject(project):
|
||||||
|
@ -41,21 +41,12 @@ def loadProject(project):
|
||||||
|
|
||||||
# Not a zip
|
# Not a zip
|
||||||
else:
|
else:
|
||||||
# Project path
|
with open(project, "r") as f:
|
||||||
dir = os.path.dirname(project)
|
version = int(f.read())
|
||||||
|
|
||||||
# Folder containing file: name of the project file (without .msk extension)
|
|
||||||
folder = os.path.splitext(os.path.basename(project))[0]
|
|
||||||
|
|
||||||
# Reading VERSION file
|
|
||||||
path = os.path.join(dir, folder, "VERSION")
|
|
||||||
if os.path.exists(path):
|
|
||||||
with open(path, "r") as f:
|
|
||||||
version = int(f.read())
|
|
||||||
|
|
||||||
print("Detected file format version:", version)
|
print("Detected file format version:", version)
|
||||||
|
|
||||||
if version == 0:
|
if version == 0 or True:
|
||||||
v0.loadProject(project)
|
v0.loadProject(project)
|
||||||
else:
|
else:
|
||||||
v1.loadProject(project)
|
v1.loadProject(project)
|
||||||
|
|
|
@ -231,6 +231,10 @@ def saveProject(zip=None):
|
||||||
moves += m
|
moves += m
|
||||||
removes += r
|
removes += r
|
||||||
|
|
||||||
|
# Writes revisions (if asked for)
|
||||||
|
if settings.revisions["keep"]:
|
||||||
|
files.append(("revisions.xml", mdl.saveToXML()))
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# World
|
# World
|
||||||
# Either in an XML file, or in lots of plain texts?
|
# Either in an XML file, or in lots of plain texts?
|
||||||
|
@ -273,10 +277,10 @@ def saveProject(zip=None):
|
||||||
# Save to zip
|
# Save to zip
|
||||||
|
|
||||||
if zip:
|
if zip:
|
||||||
project = os.path.join(
|
# project = os.path.join(
|
||||||
os.path.dirname(project),
|
# os.path.dirname(project),
|
||||||
"_" + os.path.basename(project)
|
# "_" + os.path.basename(project)
|
||||||
)
|
# )
|
||||||
|
|
||||||
zf = zipfile.ZipFile(project, mode="w")
|
zf = zipfile.ZipFile(project, mode="w")
|
||||||
|
|
||||||
|
@ -369,6 +373,10 @@ def saveProject(zip=None):
|
||||||
# Directory not empty, we don't remove.
|
# Directory not empty, we don't remove.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Write the project file's content
|
||||||
|
with open(project, "w") as f:
|
||||||
|
f.write("1") # Format number
|
||||||
|
|
||||||
|
|
||||||
def addWorldItem(root, mdl, parent=QModelIndex()):
|
def addWorldItem(root, mdl, parent=QModelIndex()):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue