mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-10 07:52:35 +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:
|
||||
v0.saveProject()
|
||||
else:
|
||||
v1.saveProject()
|
||||
v1.saveProject(zip=True)
|
||||
|
||||
|
||||
def loadProject(project):
|
||||
|
@ -41,21 +41,12 @@ def loadProject(project):
|
|||
|
||||
# Not a zip
|
||||
else:
|
||||
# Project path
|
||||
dir = os.path.dirname(project)
|
||||
|
||||
# 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())
|
||||
with open(project, "r") as f:
|
||||
version = int(f.read())
|
||||
|
||||
print("Detected file format version:", version)
|
||||
|
||||
if version == 0:
|
||||
if version == 0 or True:
|
||||
v0.loadProject(project)
|
||||
else:
|
||||
v1.loadProject(project)
|
||||
|
|
|
@ -231,6 +231,10 @@ def saveProject(zip=None):
|
|||
moves += m
|
||||
removes += r
|
||||
|
||||
# Writes revisions (if asked for)
|
||||
if settings.revisions["keep"]:
|
||||
files.append(("revisions.xml", mdl.saveToXML()))
|
||||
|
||||
####################################################################################################################
|
||||
# World
|
||||
# Either in an XML file, or in lots of plain texts?
|
||||
|
@ -273,10 +277,10 @@ def saveProject(zip=None):
|
|||
# Save to zip
|
||||
|
||||
if zip:
|
||||
project = os.path.join(
|
||||
os.path.dirname(project),
|
||||
"_" + os.path.basename(project)
|
||||
)
|
||||
# project = os.path.join(
|
||||
# os.path.dirname(project),
|
||||
# "_" + os.path.basename(project)
|
||||
# )
|
||||
|
||||
zf = zipfile.ZipFile(project, mode="w")
|
||||
|
||||
|
@ -369,6 +373,10 @@ def saveProject(zip=None):
|
|||
# Directory not empty, we don't remove.
|
||||
pass
|
||||
|
||||
# Write the project file's content
|
||||
with open(project, "w") as f:
|
||||
f.write("1") # Format number
|
||||
|
||||
|
||||
def addWorldItem(root, mdl, parent=QModelIndex()):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue