Rename package from 'nw' to 'novelwriter' (#868)

* Rename nw folder to novelwriter
* Rename nw to novelwriter in auxiliary files
* Rename nw to novelwriter in main app source
* Rename nw to novelwriter in tests
* Make setup script for pdf docs less spammy
This commit is contained in:
Veronica Berglyd Olsen
2021-08-26 17:33:54 +02:00
committed by GitHub
parent 2cf2eb9f55
commit 3403d98c72
396 changed files with 595 additions and 566 deletions
+5 -5
View File
@@ -27,9 +27,9 @@ from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextOption
from PyQt5.QtWidgets import QAction, QMessageBox, qApp
from nw.gui.doceditor import GuiDocEditor
from nw.enum import nwDocAction, nwDocInsert, nwItemClass, nwItemLayout
from nw.constants import nwKeyWords, nwUnicode
from novelwriter.gui.doceditor import GuiDocEditor
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemClass, nwItemLayout
from novelwriter.constants import nwKeyWords, nwUnicode
keyDelay = 2
typeDelay = 1
@@ -110,7 +110,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
# Document too big
with monkeypatch.context() as mp:
mp.setattr("nw.constants.nwConst.MAX_DOCSIZE", 100)
mp.setattr("novelwriter.constants.nwConst.MAX_DOCSIZE", 100)
assert nwGUI.docEditor.loadText(sHandle) is False
assert "The document you are trying to open is too big." in caplog.text
@@ -120,7 +120,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
# Reload too big text
with monkeypatch.context() as mp:
mp.setattr("nw.constants.nwConst.MAX_DOCSIZE", 100)
mp.setattr("novelwriter.constants.nwConst.MAX_DOCSIZE", 100)
assert nwGUI.docEditor.replaceText(longText) is False
assert "The document you are trying to open is too big." in caplog.text
+1 -1
View File
@@ -25,7 +25,7 @@ from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtGui import QTextCursor
from PyQt5.QtWidgets import qApp, QAction, QMessageBox
from nw.enum import nwDocAction
from novelwriter.enum import nwDocAction
keyDelay = 2
typeDelay = 1
+10 -10
View File
@@ -28,10 +28,10 @@ from tools import cmpFiles
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMessageBox, QDialog
from nw.dialogs.itemeditor import GuiItemEditor
from nw.gui.doceditor import GuiDocEditor
from nw.gui.projtree import GuiProjectTree
from nw.enum import nwItemType, nwWidget
from novelwriter.dialogs.itemeditor import GuiItemEditor
from novelwriter.gui.doceditor import GuiDocEditor
from novelwriter.gui.projtree import GuiProjectTree
from novelwriter.enum import nwItemType, nwWidget
keyDelay = 2
typeDelay = 1
@@ -43,12 +43,12 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir):
"""Test the document editor.
"""
# Block message box
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes)
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *args: None)
monkeypatch.setattr(GuiItemEditor, "result", lambda *args: QDialog.Accepted)
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True)
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *args: True)
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(QMessageBox, "information", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *a: None)
monkeypatch.setattr(GuiItemEditor, "result", lambda *a: QDialog.Accepted)
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
# Create new, save, close project
nwGUI.theProject.projTree.setSeed(42)
+3 -3
View File
@@ -28,9 +28,9 @@ from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox
from tools import writeFile
from nw.gui.doceditor import GuiDocEditor
from nw.enum import nwDocAction, nwDocInsert, nwWidget
from nw.constants import nwKeyWords, nwUnicode
from novelwriter.gui.doceditor import GuiDocEditor
from novelwriter.enum import nwDocAction, nwDocInsert, nwWidget
from novelwriter.constants import nwKeyWords, nwUnicode
keyDelay = 2
typeDelay = 1
+1 -1
View File
@@ -24,7 +24,7 @@ import pytest
from PyQt5.QtCore import Qt, QPoint
from PyQt5.QtWidgets import QAction, QTreeWidgetItem, QMessageBox
from nw.enum import nwOutline
from novelwriter.enum import nwOutline
keyDelay = 2
typeDelay = 1
+1 -1
View File
@@ -25,7 +25,7 @@ from tools import getGuiItem
from PyQt5.QtWidgets import QAction, QMessageBox
from nw.gui import GuiProjectDetails
from novelwriter.gui import GuiProjectDetails
keyDelay = 2
typeDelay = 1
+5 -5
View File
@@ -27,9 +27,9 @@ from tools import writeFile
from PyQt5.QtCore import QItemSelectionModel
from PyQt5.QtWidgets import QAction, QMessageBox
from nw.guimain import GuiMain
from nw.gui.projtree import GuiProjectTree
from nw.enum import nwItemType, nwItemClass
from novelwriter.guimain import GuiMain
from novelwriter.gui.projtree import GuiProjectTree
from novelwriter.enum import nwItemType, nwItemClass
@pytest.mark.gui
@@ -86,7 +86,7 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal):
assert nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.CUSTOM) # Valid
# Change max depth and try to add a subfolder that is too deep
monkeypatch.setattr("nw.constants.nwConst.MAX_DEPTH", 2)
monkeypatch.setattr("novelwriter.constants.nwConst.MAX_DEPTH", 2)
chItem = nwTree._getTreeItem("71ee45a3c0db9")
nwTree.setCurrentItem(chItem, QItemSelectionModel.Current)
assert not nwTree.newTreeItem(nwItemType.FOLDER, None)
@@ -228,7 +228,7 @@ def testGuiProjTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal):
nwTree.clearSelection()
# Add a file with no parent, and fail to find a suitable parent item
monkeypatch.setattr("nw.core.tree.NWTree.findRoot", lambda *a: None)
monkeypatch.setattr("novelwriter.core.tree.NWTree.findRoot", lambda *a: None)
assert not nwTree.newTreeItem(nwItemType.FILE, nwItemClass.NOVEL)
assert not nwTree.newTreeItem(nwItemType.FOLDER, nwItemClass.NOVEL)
+25 -21
View File
@@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import nw
import pytest
import novelwriter
from PyQt5.QtGui import QColor, QPixmap, QIcon
from PyQt5.QtWidgets import QStyle, QMessageBox
@@ -38,40 +38,44 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes)
monkeypatch.setattr(QMessageBox, "warning", lambda *a: QMessageBox.Yes)
nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal])
nwGUI = novelwriter.main(
["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal]
)
qtbot.addWidget(nwGUI)
nwGUI.show()
qtbot.wait(stepDelay)
# Change Settings
assert nw.CONFIG.confPath == nwMinimal
nw.CONFIG.guiTheme = "default_dark"
nw.CONFIG.guiSyntax = "tomorrow_night_eighties"
nw.CONFIG.guiIcons = "typicons_colour_dark"
nw.CONFIG.guiDark = True
nw.CONFIG.guiFont = "Cantarell"
nw.CONFIG.guiFontSize = 11
nw.CONFIG.confChanged = True
assert nw.CONFIG.saveConfig()
assert novelwriter.CONFIG.confPath == nwMinimal
novelwriter.CONFIG.guiTheme = "default_dark"
novelwriter.CONFIG.guiSyntax = "tomorrow_night_eighties"
novelwriter.CONFIG.guiIcons = "typicons_colour_dark"
novelwriter.CONFIG.guiDark = True
novelwriter.CONFIG.guiFont = "Cantarell"
novelwriter.CONFIG.guiFontSize = 11
novelwriter.CONFIG.confChanged = True
assert novelwriter.CONFIG.saveConfig()
nwGUI.closeMain()
nwGUI.close()
del nwGUI
# Re-open
assert nw.CONFIG.confPath == nwMinimal
nwGUI = nw.main(["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal])
assert novelwriter.CONFIG.confPath == nwMinimal
nwGUI = novelwriter.main(
["--testmode", "--config=%s" % nwMinimal, "--data=%s" % tmpDir, nwMinimal]
)
assert nwGUI.mainConf.confPath == nwMinimal
qtbot.addWidget(nwGUI)
nwGUI.show()
qtbot.wait(stepDelay)
assert nw.CONFIG.guiTheme == "default_dark"
assert nw.CONFIG.guiSyntax == "tomorrow_night_eighties"
assert nw.CONFIG.guiIcons == "typicons_colour_dark"
assert nw.CONFIG.guiDark is True
assert nw.CONFIG.guiFont == "Cantarell"
assert nw.CONFIG.guiFontSize == 11
assert novelwriter.CONFIG.guiTheme == "default_dark"
assert novelwriter.CONFIG.guiSyntax == "tomorrow_night_eighties"
assert novelwriter.CONFIG.guiIcons == "typicons_colour_dark"
assert novelwriter.CONFIG.guiDark is True
assert novelwriter.CONFIG.guiFont == "Cantarell"
assert novelwriter.CONFIG.guiFontSize == 11
# Check GUI Colours
thePalette = nwGUI.palette()
@@ -114,9 +118,9 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
# Test Icon class
theIcons = nwGUI.theTheme.theIcons
nw.CONFIG.guiIcons = "invalid"
novelwriter.CONFIG.guiIcons = "invalid"
assert not theIcons.updateTheme()
nw.CONFIG.guiIcons = "typicons_colour_dark"
novelwriter.CONFIG.guiIcons = "typicons_colour_dark"
assert theIcons.updateTheme()
# Ask for a non-existent key