From 6b16b7c3b7bf022c99092525488ba18aa10d3594 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Thu, 20 Oct 2022 18:28:32 +0200
Subject: [PATCH] Rename project file attribute
---
novelwriter/core/item.py | 36 ++++++++-------
sample/nwProject.nwx | 44 +++++++++----------
tests/lipsum/nwProject.nwx | 30 ++++++-------
tests/minimal/nwProject.nwx | 6 +--
.../coreProject_NewCustomA_nwProject.nwx | 34 +++++++-------
.../coreProject_NewCustomB_nwProject.nwx | 22 +++++-----
.../coreProject_NewFileFolder_nwProject.nwx | 12 ++---
.../coreProject_NewMinimal_nwProject.nwx | 8 ++--
.../coreProject_NewRoot_nwProject.nwx | 8 ++--
.../guiEditor_Main_Final_nwProject.nwx | 14 +++---
.../guiEditor_Main_Initial_nwProject.nwx | 8 ++--
.../guiProjSettings_Dialog_nwProject.nwx | 8 ++--
tests/test_core/test_core_item.py | 2 +-
tests/test_core/test_core_tree.py | 6 +--
14 files changed, 121 insertions(+), 117 deletions(-)
diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py
index d8bbc88e..40426d67 100644
--- a/novelwriter/core/item.py
+++ b/novelwriter/core/item.py
@@ -52,8 +52,8 @@ class NWItem:
self._layout = nwItemLayout.NO_LAYOUT
self._status = None
self._import = None
+ self._active = True
self._expanded = False
- self._exported = True
# Document Meta Data
self._heading = "H0" # The main heading
@@ -116,12 +116,12 @@ class NWItem:
return self._import
@property
- def isExpanded(self):
- return self._expanded
+ def isActive(self):
+ return self._active
@property
- def isActive(self):
- return self._exported
+ def isExpanded(self):
+ return self._expanded
@property
def mainHeading(self):
@@ -177,7 +177,7 @@ class NWItem:
nameAttrib["status"] = str(self._status)
nameAttrib["import"] = str(self._import)
if self._type == nwItemType.FILE:
- nameAttrib["exported"] = str(self._exported)
+ nameAttrib["active"] = str(self._active)
xPack = etree.SubElement(xParent, "item", attrib=itemAttrib)
self._subPack(xPack, "meta", attrib=metaAttrib)
@@ -217,7 +217,11 @@ class NWItem:
self.setName(xValue.text)
self.setStatus(xValue.attrib.get("status", None))
self.setImport(xValue.attrib.get("import", None))
- self.setActive(xValue.attrib.get("exported", True))
+ self.setActive(xValue.attrib.get("active", True))
+
+ # ToDo: Remove before 2.0 release. Only needed for 2.0 pre-releases.
+ if "exported" in xValue.attrib:
+ self.setActive(xValue.attrib.get("exported", True))
# Legacy Format (1.3 and earlier)
elif xValue.tag == "status":
@@ -496,6 +500,15 @@ class NWItem:
self._import = self.theProject.importItems.check(value)
return
+ def setActive(self, state):
+ """Set the export flag.
+ """
+ if isinstance(state, str):
+ self._active = (state == str(True))
+ else:
+ self._active = (state is True)
+ return
+
def setExpanded(self, state):
"""Set the expanded status of an item in the project tree.
"""
@@ -505,15 +518,6 @@ class NWItem:
self._expanded = (state is True)
return
- def setActive(self, state):
- """Set the export flag.
- """
- if isinstance(state, str):
- self._exported = (state == str(True))
- else:
- self._exported = (state is True)
- return
-
##
# Set Document Meta Data
##
diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx
index 75f59236..e32d66f8 100644
--- a/sample/nwProject.nwx
+++ b/sample/nwProject.nwx
@@ -1,13 +1,13 @@
-
+
Sample Project
Sample Project
Jane Smith
Jay Doh
- 1383
+ 1385
236
- 69344
+ 69348
False
@@ -56,43 +56,43 @@
-
- Title Page
+ Title Page
-
- Page
+ Page
-
- Part One
+ Part One
-
- Chapter One
+ Chapter One
-
- Making a Scene
+ Making a Scene
-
- Another Scene
+ Another Scene
-
- Interlude
+ Interlude
-
- A Note on Structure
+ A Note on Structure
-
- Chapter Two
+ Chapter Two
-
- We Found John!
+ We Found John!
-
@@ -100,11 +100,11 @@
-
- Title Page
+ Title Page
-
- Chapter One
+ Chapter One
-
@@ -116,11 +116,11 @@
-
- John Smith
+ John Smith
-
- Jane Smith
+ Jane Smith
-
@@ -128,15 +128,15 @@
-
- Earth
+ Earth
-
- Space
+ Space
-
- Mars
+ Mars
-
@@ -148,7 +148,7 @@
-
- Old File
+ Old File
-
@@ -156,7 +156,7 @@
-
- Delete Me!
+ Delete Me!
diff --git a/tests/lipsum/nwProject.nwx b/tests/lipsum/nwProject.nwx
index ea5519c4..bfaedd84 100644
--- a/tests/lipsum/nwProject.nwx
+++ b/tests/lipsum/nwProject.nwx
@@ -51,19 +51,19 @@
-
- Lorem Ipsum
+ Lorem Ipsum
-
- Front Matter
+ Front Matter
-
- Prologue
+ Prologue
-
- Act One
+ Act One
-
@@ -71,19 +71,19 @@
-
- Chapter One
+ Chapter One
-
- Scene One
+ Scene One
-
- Scene Two
+ Scene Two
-
- Interlude
+ Interlude
-
@@ -91,19 +91,19 @@
-
- Chapter Two
+ Chapter Two
-
- Scene Three
+ Scene Three
-
- Scene Four
+ Scene Four
-
- Scene Five
+ Scene Five
-
@@ -111,7 +111,7 @@
-
- Mr. Nobody
+ Mr. Nobody
-
@@ -119,7 +119,7 @@
-
- Main
+ Main
-
@@ -127,7 +127,7 @@
-
- Ancient Europe
+ Ancient Europe
diff --git a/tests/minimal/nwProject.nwx b/tests/minimal/nwProject.nwx
index 99f81105..b9180838 100644
--- a/tests/minimal/nwProject.nwx
+++ b/tests/minimal/nwProject.nwx
@@ -49,7 +49,7 @@
-
- Title Page
+ Title Page
-
@@ -57,11 +57,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
diff --git a/tests/reference/coreProject_NewCustomA_nwProject.nwx b/tests/reference/coreProject_NewCustomA_nwProject.nwx
index c61b7f3f..ef2056f7 100644
--- a/tests/reference/coreProject_NewCustomA_nwProject.nwx
+++ b/tests/reference/coreProject_NewCustomA_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
Test Custom
Test Novel
@@ -49,55 +49,55 @@
-
- Title Page
+ Title Page
-
- Chapter 1
+ Chapter 1
-
- Scene 1.1
+ Scene 1.1
-
- Scene 1.2
+ Scene 1.2
-
- Scene 1.3
+ Scene 1.3
-
- Chapter 2
+ Chapter 2
-
- Scene 2.1
+ Scene 2.1
-
- Scene 2.2
+ Scene 2.2
-
- Scene 2.3
+ Scene 2.3
-
- Chapter 3
+ Chapter 3
-
- Scene 3.1
+ Scene 3.1
-
- Scene 3.2
+ Scene 3.2
-
- Scene 3.3
+ Scene 3.3
-
@@ -105,7 +105,7 @@
-
- Main Plot
+ Main Plot
-
@@ -113,7 +113,7 @@
-
- Protagonist
+ Protagonist
-
@@ -121,7 +121,7 @@
-
- Main Location
+ Main Location
-
diff --git a/tests/reference/coreProject_NewCustomB_nwProject.nwx b/tests/reference/coreProject_NewCustomB_nwProject.nwx
index 9bc1bbf0..30d6c2a9 100644
--- a/tests/reference/coreProject_NewCustomB_nwProject.nwx
+++ b/tests/reference/coreProject_NewCustomB_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
Test Custom
Test Novel
@@ -49,31 +49,31 @@
-
- Title Page
+ Title Page
-
- Scene 1
+ Scene 1
-
- Scene 2
+ Scene 2
-
- Scene 3
+ Scene 3
-
- Scene 4
+ Scene 4
-
- Scene 5
+ Scene 5
-
- Scene 6
+ Scene 6
-
@@ -81,7 +81,7 @@
-
- Main Plot
+ Main Plot
-
@@ -89,7 +89,7 @@
-
- Protagonist
+ Protagonist
-
@@ -97,7 +97,7 @@
-
- Main Location
+ Main Location
-
diff --git a/tests/reference/coreProject_NewFileFolder_nwProject.nwx b/tests/reference/coreProject_NewFileFolder_nwProject.nwx
index 94655075..e1faf5a7 100644
--- a/tests/reference/coreProject_NewFileFolder_nwProject.nwx
+++ b/tests/reference/coreProject_NewFileFolder_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
New Novel
@@ -60,7 +60,7 @@
-
- Title Page
+ Title Page
-
@@ -68,11 +68,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
@@ -80,11 +80,11 @@
-
- Hello
+ Hello
-
- Jane
+ Jane
diff --git a/tests/reference/coreProject_NewMinimal_nwProject.nwx b/tests/reference/coreProject_NewMinimal_nwProject.nwx
index 08a5d568..282aa1f3 100644
--- a/tests/reference/coreProject_NewMinimal_nwProject.nwx
+++ b/tests/reference/coreProject_NewMinimal_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
@@ -47,15 +47,15 @@
-
- Title Page
+ Title Page
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
diff --git a/tests/reference/coreProject_NewRoot_nwProject.nwx b/tests/reference/coreProject_NewRoot_nwProject.nwx
index 24be3ad5..af7e0b73 100644
--- a/tests/reference/coreProject_NewRoot_nwProject.nwx
+++ b/tests/reference/coreProject_NewRoot_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
New Novel
@@ -60,7 +60,7 @@
-
- Title Page
+ Title Page
-
@@ -68,11 +68,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx
index 1f8718b2..fb58330e 100644
--- a/tests/reference/guiEditor_Main_Final_nwProject.nwx
+++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
New Novel
@@ -48,7 +48,7 @@
-
- Title Page
+ Title Page
-
@@ -56,11 +56,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
@@ -68,7 +68,7 @@
-
- New Note
+ New Note
-
@@ -76,7 +76,7 @@
-
- New Note
+ New Note
-
@@ -84,7 +84,7 @@
-
- New Note
+ New Note
-
diff --git a/tests/reference/guiEditor_Main_Initial_nwProject.nwx b/tests/reference/guiEditor_Main_Initial_nwProject.nwx
index 2ee65716..aa3b3057 100644
--- a/tests/reference/guiEditor_Main_Initial_nwProject.nwx
+++ b/tests/reference/guiEditor_Main_Initial_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
New Novel
@@ -48,7 +48,7 @@
-
- Title Page
+ Title Page
-
@@ -56,11 +56,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
diff --git a/tests/reference/guiProjSettings_Dialog_nwProject.nwx b/tests/reference/guiProjSettings_Dialog_nwProject.nwx
index cff9285d..307aae55 100644
--- a/tests/reference/guiProjSettings_Dialog_nwProject.nwx
+++ b/tests/reference/guiProjSettings_Dialog_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
Project Name
Project Title
@@ -53,7 +53,7 @@
-
- Title Page
+ Title Page
-
@@ -61,11 +61,11 @@
-
- New Chapter
+ New Chapter
-
- New Scene
+ New Scene
-
diff --git a/tests/test_core/test_core_item.py b/tests/test_core/test_core_item.py
index 97688df5..e7a72336 100644
--- a/tests/test_core/test_core_item.py
+++ b/tests/test_core/test_core_item.py
@@ -527,7 +527,7 @@ def testCoreItem_XMLPackUnpack(mockGUI, caplog, mockRnd):
b'
- A Name
'
+ b'import="%s" active="False">A Name '
b''
) % bytes(importKeys[3], encoding="utf8")
diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py
index c3c20d34..588d23f5 100644
--- a/tests/test_core/test_core_tree.py
+++ b/tests/test_core/test_core_tree.py
@@ -422,11 +422,11 @@ def testCoreTree_XMLPackUnpack(mockGUI, mockItems):
b'- Chapter One
'
+ b'import="i000004" active="True">Chapter One'
b'- Scene One
'
+ b'import="i000004" active="True">Scene One'
b'- Outtakes
'
@@ -439,7 +439,7 @@ def testCoreTree_XMLPackUnpack(mockGUI, mockItems):
b'- Jane Doe
'
+ b'import="i000004" active="True">Jane Doe'
b''
b''
)