Fix docstring and rename NWIndex to just Index
This commit is contained in:
@@ -3,9 +3,7 @@ novelWriter – Project Index
|
|||||||
===========================
|
===========================
|
||||||
|
|
||||||
File History:
|
File History:
|
||||||
Created: 2019-05-27 [0.1.4] NWIndex
|
Created: 2019-05-27 [0.1.4] Index
|
||||||
Created: 2022-05-28 [2.0rc1] IndexNode
|
|
||||||
Created: 2022-05-28 [2.0rc1] IndexHeading
|
|
||||||
Created: 2022-05-29 [2.0rc1] TagsIndex
|
Created: 2022-05-29 [2.0rc1] TagsIndex
|
||||||
Created: 2022-05-29 [2.0rc1] ItemIndex
|
Created: 2022-05-29 [2.0rc1] ItemIndex
|
||||||
|
|
||||||
@@ -55,7 +53,7 @@ MAX_RETRY = 1000 # Key generator recursion limit
|
|||||||
KEY_SOURCE = "0123456789bcdfghjklmnpqrstvwxz"
|
KEY_SOURCE = "0123456789bcdfghjklmnpqrstvwxz"
|
||||||
|
|
||||||
|
|
||||||
class NWIndex:
|
class Index:
|
||||||
"""Core: Project Index
|
"""Core: Project Index
|
||||||
|
|
||||||
This class holds the entire index for a given project. The index
|
This class holds the entire index for a given project. The index
|
||||||
@@ -98,7 +96,7 @@ class NWIndex:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<NWIndex project='{self._project.data.name}'>"
|
return f"<Index project='{self._project.data.name}'>"
|
||||||
|
|
||||||
##
|
##
|
||||||
# Properties
|
# Properties
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ novelWriter – Project Index Data
|
|||||||
File History:
|
File History:
|
||||||
Created: 2022-05-28 [2.0rc1] IndexNode
|
Created: 2022-05-28 [2.0rc1] IndexNode
|
||||||
Created: 2022-05-28 [2.0rc1] IndexHeading
|
Created: 2022-05-28 [2.0rc1] IndexHeading
|
||||||
|
Moved: 2025-02-22 [2.7b1] IndexNode
|
||||||
|
Moved: 2025-02-22 [2.7b1] IndexHeading
|
||||||
|
|
||||||
This file is a part of novelWriter
|
This file is a part of novelWriter
|
||||||
Copyright (C) 2022 Veronica Berglyd Olsen and novelWriter contributors
|
Copyright (C) 2025 Veronica Berglyd Olsen and novelWriter contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ from novelwriter.common import (
|
|||||||
makeFileNameSafe, minmax
|
makeFileNameSafe, minmax
|
||||||
)
|
)
|
||||||
from novelwriter.constants import nwLabels, trConst
|
from novelwriter.constants import nwLabels, trConst
|
||||||
from novelwriter.core.index import NWIndex
|
from novelwriter.core.index import Index
|
||||||
from novelwriter.core.options import OptionState
|
from novelwriter.core.options import OptionState
|
||||||
from novelwriter.core.projectdata import NWProjectData
|
from novelwriter.core.projectdata import NWProjectData
|
||||||
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
||||||
@@ -75,7 +75,7 @@ class NWProject:
|
|||||||
self._storage = NWStorage(self) # The project storage handler
|
self._storage = NWStorage(self) # The project storage handler
|
||||||
self._data = NWProjectData(self) # The project settings
|
self._data = NWProjectData(self) # The project settings
|
||||||
self._tree = NWTree(self) # The project tree
|
self._tree = NWTree(self) # The project tree
|
||||||
self._index = NWIndex(self) # The project index
|
self._index = Index(self) # The project index
|
||||||
self._session = NWSessionLog(self) # The session record
|
self._session = NWSessionLog(self) # The session record
|
||||||
|
|
||||||
# Project Status
|
# Project Status
|
||||||
@@ -122,7 +122,7 @@ class NWProject:
|
|||||||
return self._tree
|
return self._tree
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def index(self) -> NWIndex:
|
def index(self) -> Index:
|
||||||
return self._index
|
return self._index
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
novelWriter – NWIndex Class Tester
|
novelWriter – Index Class Tester
|
||||||
==================================
|
================================
|
||||||
|
|
||||||
This file is a part of novelWriter
|
This file is a part of novelWriter
|
||||||
Copyright (C) 2020 Veronica Berglyd Olsen and novelWriter contributors
|
Copyright (C) 2020 Veronica Berglyd Olsen and novelWriter contributors
|
||||||
@@ -28,7 +28,7 @@ import pytest
|
|||||||
|
|
||||||
from novelwriter import SHARED
|
from novelwriter import SHARED
|
||||||
from novelwriter.constants import nwFiles
|
from novelwriter.constants import nwFiles
|
||||||
from novelwriter.core.index import IndexNode, NWIndex, TagsIndex
|
from novelwriter.core.index import Index, IndexNode, TagsIndex
|
||||||
from novelwriter.core.item import NWItem
|
from novelwriter.core.item import NWItem
|
||||||
from novelwriter.core.project import NWProject
|
from novelwriter.core.project import NWProject
|
||||||
from novelwriter.enum import nwComment, nwItemClass, nwItemLayout
|
from novelwriter.enum import nwComment, nwItemClass, nwItemLayout
|
||||||
@@ -49,8 +49,8 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths):
|
|||||||
project = NWProject()
|
project = NWProject()
|
||||||
assert project.openProject(prjLipsum)
|
assert project.openProject(prjLipsum)
|
||||||
|
|
||||||
index = NWIndex(project)
|
index = Index(project)
|
||||||
assert repr(index) == "<NWIndex project='Lorem Ipsum'>"
|
assert repr(index) == "<Index project='Lorem Ipsum'>"
|
||||||
|
|
||||||
notIndexable = {
|
notIndexable = {
|
||||||
"b3643d0f92e32": False, # Novel ROOT
|
"b3643d0f92e32": False, # Novel ROOT
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
novelWriter – NWIndex Class Tester
|
novelWriter – Index Data Class Tester
|
||||||
==================================
|
====================================
|
||||||
|
|
||||||
This file is a part of novelWriter
|
This file is a part of novelWriter
|
||||||
Copyright (C) 2020 Veronica Berglyd Olsen and novelWriter contributors
|
Copyright (C) 2020 Veronica Berglyd Olsen and novelWriter contributors
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
|
|||||||
# Trigger an index rebuild
|
# Trigger an index rebuild
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(ProjectXMLReader, "state", property(lambda *a: XMLReadState.WAS_LEGACY))
|
mp.setattr(ProjectXMLReader, "state", property(lambda *a: XMLReadState.WAS_LEGACY))
|
||||||
mp.setattr("novelwriter.core.index.NWIndex.loadIndex", lambda *a: True)
|
mp.setattr("novelwriter.core.index.Index.loadIndex", lambda *a: True)
|
||||||
project.index._indexBroken = True
|
project.index._indexBroken = True
|
||||||
assert project.openProject(fncPath, clearLock=True) is True
|
assert project.openProject(fncPath, clearLock=True) is True
|
||||||
assert "The file format of your project is about to be" in SHARED.lastAlert
|
assert "The file format of your project is about to be" in SHARED.lastAlert
|
||||||
|
|||||||
Reference in New Issue
Block a user