diff --git a/novelwriter/formats/tokenizer.py b/novelwriter/formats/tokenizer.py index 93caa96e..f01d6e85 100644 --- a/novelwriter/formats/tokenizer.py +++ b/novelwriter/formats/tokenizer.py @@ -24,21 +24,17 @@ along with this program. If not, see . """ from __future__ import annotations -import json import logging import re from abc import ABC, abstractmethod -from functools import partial from pathlib import Path -from time import time from typing import NamedTuple -from PyQt5.QtCore import QCoreApplication from PyQt5.QtGui import QColor, QFont from novelwriter import CONFIG -from novelwriter.common import checkInt, formatTimeStamp, numberToRoman +from novelwriter.common import checkInt, numberToRoman from novelwriter.constants import ( nwHeadFmt, nwKeyWords, nwLabels, nwShortcode, nwStyles, nwUnicode, trConst ) @@ -179,7 +175,6 @@ class Tokenizer(ABC): # Function Mapping self._localLookup = self._project.localLookup - self.tr = partial(QCoreApplication.translate, "Tokenizer") # Format RegEx self._rxMarkdown = [ @@ -1024,33 +1019,6 @@ class Tokenizer(ABC): return - def saveRawDocument(self, path: str | Path, asJson: bool = False) -> None: - """Save the raw text to a plain text file.""" - if asJson: - ts = time() - data = { - "meta": { - "projectName": self._project.data.name, - "novelAuthor": self._project.data.author, - "buildTime": int(ts), - "buildTimeStr": formatTimeStamp(ts), - }, - "text": { - "nwd": [page.rstrip("\n").split("\n") for page in self._raw], - } - } - with open(path, mode="w", encoding="utf-8") as fObj: - json.dump(data, fObj, indent=2) - - else: - with open(path, mode="w", encoding="utf-8") as outFile: - for nwdPage in self._raw: - outFile.write(nwdPage) - - logger.info("Wrote file: %s", path) - - return - ## # Internal Functions ## diff --git a/tests/test_formats/test_fmt_tokenizer.py b/tests/test_formats/test_fmt_tokenizer.py index e571afe2..3750af7a 100644 --- a/tests/test_formats/test_fmt_tokenizer.py +++ b/tests/test_formats/test_fmt_tokenizer.py @@ -20,8 +20,6 @@ along with this program. If not, see . """ from __future__ import annotations -import json - import pytest from PyQt5.QtGui import QFont @@ -35,7 +33,7 @@ from novelwriter.formats.tokenizer import COMMENT_STYLE, HeadingFormatter, Token from novelwriter.formats.tomarkdown import ToMarkdown from novelwriter.formats.toraw import ToRaw -from tests.tools import C, buildTestProject, readFile +from tests.tools import C, buildTestProject TMH = "0123456789abc" TM1 = f"{TMH}:T0001" @@ -237,21 +235,6 @@ def testFmtToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath): tokens.doPreProcessing() assert tokens._text == docTextR - # Save File - savePath = fncPath / "dump.nwd" - tokens.saveRawDocument(savePath, asJson=False) - assert readFile(savePath) == ( - "#! Notes: Plot\n\n" - "#! Notes: Plot\n\n" - ) - tokens.saveRawDocument(savePath, asJson=True) - assert json.loads(readFile(savePath))["text"] == { - "nwd": [ - ["#! Notes: Plot"], - ["#! Notes: Plot"] - ] - } - @pytest.mark.core def testFmtToken_StripEscape():