mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-16 18:04:33 +12:00
Converted most print statements to use logging
Some snippets have yet to be converted due to the more complex nature of those snippets, and to keep things neat a separate commit makes more sense for those.
This commit is contained in:
parent
8884bac0ed
commit
ff2cbca028
|
@ -11,6 +11,9 @@ from PyQt5.QtGui import QCursor
|
|||
from manuskript.converters import abstractConverter
|
||||
from manuskript.functions import mainWindow
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import markdown as MD
|
||||
except ImportError:
|
||||
|
@ -31,7 +34,7 @@ class markdownConverter(abstractConverter):
|
|||
@classmethod
|
||||
def convert(self, markdown):
|
||||
if not self.isValid:
|
||||
print("ERROR: markdownConverter is called but not valid.")
|
||||
LOGGER.error("markdownConverter is called but not valid.")
|
||||
return ""
|
||||
|
||||
html = MD.markdown(markdown)
|
||||
|
|
|
@ -11,6 +11,8 @@ from PyQt5.QtGui import QCursor
|
|||
from manuskript.converters import abstractConverter
|
||||
from manuskript.functions import mainWindow
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class pandocConverter(abstractConverter):
|
||||
|
||||
|
@ -38,7 +40,7 @@ class pandocConverter(abstractConverter):
|
|||
@classmethod
|
||||
def convert(self, src, _from="markdown", to="html", args=None, outputfile=None):
|
||||
if not self.isValid:
|
||||
print("ERROR: pandocConverter is called but not valid.")
|
||||
LOGGER.error("pandocConverter is called but not valid.")
|
||||
return ""
|
||||
|
||||
cmd = [self.runCmd()]
|
||||
|
@ -70,7 +72,7 @@ class pandocConverter(abstractConverter):
|
|||
|
||||
if stderr:
|
||||
err = stderr.decode("utf-8")
|
||||
print(err)
|
||||
LOGGER.error(err)
|
||||
QMessageBox.critical(mainWindow().dialog,
|
||||
qApp.translate("Export", "Error"), err)
|
||||
return None
|
||||
|
|
|
@ -10,6 +10,8 @@ from PyQt5.QtWidgets import QWidget
|
|||
from manuskript.models import outlineItem
|
||||
from manuskript.functions import mainWindow
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class basicExporter:
|
||||
|
||||
|
@ -58,7 +60,7 @@ class basicExporter:
|
|||
elif self.isValid() == 1:
|
||||
run = self.customPath
|
||||
else:
|
||||
print("Error: no command for", self.name)
|
||||
LOGGER.error("No command for %s.", self.name)
|
||||
return None
|
||||
r = subprocess.check_output([run] + args) # timeout=.2
|
||||
return r.decode("utf-8")
|
||||
|
@ -71,7 +73,7 @@ class basicExporter:
|
|||
# try:
|
||||
# output = subprocess.check_output(cmdl, stdin=cmd.stdout, stderr=subprocess.STDOUT) # , cwd="/tmp"
|
||||
# except subprocess.CalledProcessError as e:
|
||||
# print("Error!")
|
||||
# LOGGER.error("Failed to read from process output.")
|
||||
# return text
|
||||
# cmd.wait()
|
||||
#
|
||||
|
|
|
@ -10,6 +10,9 @@ from manuskript.models import outlineItem
|
|||
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
||||
import codecs
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class plainText(basicFormat):
|
||||
name = qApp.translate("Export", "Plain text")
|
||||
description = qApp.translate("Export", """Simplest export to plain text. Allows you to use your own markup not understood
|
||||
|
@ -90,7 +93,7 @@ class plainText(basicFormat):
|
|||
content = self.output(settingsWidget)
|
||||
|
||||
if not content:
|
||||
print("Error: No content. Nothing saved.")
|
||||
LOGGER.error("No content. Nothing saved.")
|
||||
return
|
||||
|
||||
with open(filename, "w", encoding='utf8') as f:
|
||||
|
|
|
@ -13,6 +13,8 @@ from manuskript.exporter.pandoc.outputFormats import ePub, OpenDocument, DocX
|
|||
from manuskript.exporter.pandoc.plainText import reST, markdown, latex, OPML
|
||||
from manuskript.functions import mainWindow
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class pandocExporter(basicExporter):
|
||||
|
||||
|
@ -53,7 +55,7 @@ class pandocExporter(basicExporter):
|
|||
elif self.isValid() == 1:
|
||||
run = self.customPath
|
||||
else:
|
||||
print("Error: no command for pandoc")
|
||||
LOGGER.error("No command for pandoc.")
|
||||
return None
|
||||
args = [run] + args
|
||||
|
||||
|
@ -101,7 +103,7 @@ class pandocExporter(basicExporter):
|
|||
+ "Return code" + ": %d\n" % (p.returncode) \
|
||||
+ "Command and parameters" + ":\n%s\n" % (p.args) \
|
||||
+ "Stderr content" + ":\n" + stderr.decode("utf-8")
|
||||
print(err)
|
||||
LOGGER.error(err)
|
||||
QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
|
||||
return None
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import zipfile
|
|||
import manuskript.load_save.version_0 as v0
|
||||
import manuskript.load_save.version_1 as v1
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def saveProject(version=None):
|
||||
|
||||
|
@ -57,8 +59,8 @@ def loadProject(project):
|
|||
with open(project, "r", encoding="utf-8") as f:
|
||||
version = int(f.read())
|
||||
|
||||
print("Loading:", project)
|
||||
print("Detected file format version: {}. Zip: {}.".format(version, isZip))
|
||||
LOGGER.info("Loading: %s", project)
|
||||
LOGGER.info("Detected file format version: {}. Zip: {}.".format(version, isZip))
|
||||
|
||||
if version == 0:
|
||||
v0.loadProject(project)
|
||||
|
|
|
@ -16,6 +16,9 @@ from manuskript import settings
|
|||
from manuskript.functions import iconColor, iconFromColorString, mainWindow
|
||||
from manuskript.models.characterModel import Character, CharacterInfo
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import zlib # Used with zipfile for compression
|
||||
|
||||
|
@ -37,7 +40,7 @@ def saveProject():
|
|||
|
||||
files.append((saveStandardItemModelXML(mw.mdlFlatData),
|
||||
"flatModel.xml"))
|
||||
print("ERROR: file format 0 does not save characters !")
|
||||
LOGGER.error("File format 0 does not save characters!")
|
||||
# files.append((saveStandardItemModelXML(mw.mdlCharacter),
|
||||
# "perso.xml"))
|
||||
files.append((saveStandardItemModelXML(mw.mdlWorld),
|
||||
|
@ -91,7 +94,7 @@ def saveStandardItemModelXML(mdl, xml=None):
|
|||
data = ET.SubElement(root, "data")
|
||||
saveItem(data, mdl)
|
||||
|
||||
# print(qApp.tr("Saving to {}.").format(xml))
|
||||
# LOGGER.info("Saving to {}.".format(xml))
|
||||
if xml:
|
||||
ET.ElementTree(root).write(xml, encoding="UTF-8", xml_declaration=True, pretty_print=True)
|
||||
else:
|
||||
|
@ -189,13 +192,13 @@ def loadStandardItemModelXML(mdl, xml, fromString=False):
|
|||
"""Load data to a QStandardItemModel mdl from xml.
|
||||
By default xml is a filename. If fromString=True, xml is a string containing the data."""
|
||||
|
||||
# print(qApp.tr("Loading {}... ").format(xml), end="")
|
||||
# LOGGER.info("Loading {}...".format(xml))
|
||||
|
||||
if not fromString:
|
||||
try:
|
||||
tree = ET.parse(xml)
|
||||
except:
|
||||
print("Failed.")
|
||||
LOGGER.error("Failed to load XML for QStandardItemModel (%s).", xml)
|
||||
return
|
||||
else:
|
||||
root = ET.fromstring(xml)
|
||||
|
@ -210,7 +213,7 @@ def loadStandardItemModelXML(mdl, xml, fromString=False):
|
|||
for l in root.find("header").find("vertical").findall("label"):
|
||||
vLabels.append(l.attrib["text"])
|
||||
|
||||
# print(root.find("header").find("vertical").text)
|
||||
# LOGGER.debug(root.find("header").find("vertical").text)
|
||||
|
||||
# mdl.setVerticalHeaderLabels(vLabels)
|
||||
# mdl.setHorizontalHeaderLabels(hLabels)
|
||||
|
|
|
@ -26,6 +26,9 @@ from manuskript.load_save.version_0 import loadFilesFromZip
|
|||
from manuskript.models.characterModel import CharacterInfo
|
||||
from manuskript.models import outlineItem
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import zlib # Used with zipfile for compression
|
||||
|
||||
|
@ -125,7 +128,7 @@ def saveProject(zip=None):
|
|||
|
||||
# Sanity check (see PR-583): make sure we actually have a current project.
|
||||
if project == None:
|
||||
print("Error: cannot save project because there is no current project in the UI.")
|
||||
LOGGER.error("Cannot save project because there is no current project in the UI.")
|
||||
return False
|
||||
|
||||
# File format version
|
||||
|
@ -307,7 +310,7 @@ def saveProject(zip=None):
|
|||
# not exist, we check the parent folder, because it might be a new project.
|
||||
if os.path.exists(project) and not os.access(project, os.W_OK) or \
|
||||
not os.path.exists(project) and not os.access(os.path.dirname(project), os.W_OK):
|
||||
print("Error: you don't have write access to save this project there.")
|
||||
LOGGER.error("You don't have write access to save this project there.")
|
||||
return False
|
||||
|
||||
####################################################################################################################
|
||||
|
@ -924,7 +927,7 @@ def addTextItems(mdl, odict, parent=None):
|
|||
item._lastPath = odict[k + ":lastPath"]
|
||||
|
||||
elif not ":lastPath" in k and k != "folder.txt":
|
||||
print("* Strange things in file {}".format(k))
|
||||
LOGGER.debug("Strange things in file %s".format(k))
|
||||
|
||||
|
||||
def outlineFromMMD(text, parent):
|
||||
|
|
|
@ -18,7 +18,7 @@ from manuskript.version import getVersion
|
|||
faulthandler.enable()
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def prepare(arguments, tests=False):
|
||||
app = QApplication(sys.argv)
|
||||
|
@ -34,7 +34,7 @@ def prepare(arguments, tests=False):
|
|||
# Handle all sorts of Qt logging messages in Python.
|
||||
manuskript.logging.integrateQtLogging()
|
||||
|
||||
logger.info("Running manuskript version {}.".format(getVersion()))
|
||||
LOGGER.info("Running manuskript version {}.".format(getVersion()))
|
||||
icon = QIcon()
|
||||
for i in [16, 32, 64, 128, 256, 512]:
|
||||
icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
|
||||
|
@ -57,7 +57,7 @@ def prepare(arguments, tests=False):
|
|||
"""Tries to load and activate a given translation for use."""
|
||||
if appTranslator.load(translation, appPath("i18n")):
|
||||
app.installTranslator(appTranslator)
|
||||
logger.info("Loaded translation: {}".format(translation))
|
||||
LOGGER.info("Loaded translation: {}".format(translation))
|
||||
# Note: QTranslator.load() does some fancy heuristics where it simplifies
|
||||
# the given locale until it is 'close enough' if the given filename does
|
||||
# not work out. For example, if given 'i18n/manuskript_en_US.qm', it tries:
|
||||
|
@ -72,7 +72,7 @@ def prepare(arguments, tests=False):
|
|||
# filenames when you observe strange behaviour with the loaded translations.
|
||||
return True
|
||||
else:
|
||||
logger.info("No translation found or loaded. ({})".format(translation))
|
||||
LOGGER.info("No translation found or loaded. ({})".format(translation))
|
||||
return False
|
||||
|
||||
def activateTranslation(translation, source):
|
||||
|
@ -95,7 +95,7 @@ def prepare(arguments, tests=False):
|
|||
break
|
||||
|
||||
if using_builtin_translation:
|
||||
logger.info("Using the builtin translation. (U.S. English)")
|
||||
LOGGER.info("Using the builtin translation. (U.S. English)")
|
||||
|
||||
# Load application translation
|
||||
translation = ""
|
||||
|
@ -109,7 +109,7 @@ def prepare(arguments, tests=False):
|
|||
translation = QLocale().uiLanguages()
|
||||
source = "available ui languages"
|
||||
|
||||
logger.info("Preferred translation: {} (based on {})".format(("builtin" if translation == "" else translation), source))
|
||||
LOGGER.info("Preferred translation: {} (based on {})".format(("builtin" if translation == "" else translation), source))
|
||||
activateTranslation(translation, source)
|
||||
|
||||
def respectSystemDarkThemeSetting():
|
||||
|
@ -241,6 +241,8 @@ def launch(arguments, app, MW = None):
|
|||
|
||||
def sigint_handler(sig, MW):
|
||||
def handler(*args):
|
||||
# Log before winding down to preserve order of cause and effect.
|
||||
LOGGER.info(f'{sig} received. Quitting...')
|
||||
MW.close()
|
||||
print(f'{sig} received, quit.')
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ from manuskript.ui.statusLabel import statusLabel
|
|||
from manuskript.ui.views.textEditView import textEditView
|
||||
from manuskript.functions import Spellchecker
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# dictChanged = pyqtSignal(str)
|
||||
|
||||
|
@ -584,7 +587,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
If ``loadFromFile`` is False, then it does not load datas from file.
|
||||
It assumes that the datas have been populated in a different way."""
|
||||
if loadFromFile and not os.path.exists(project):
|
||||
print(self.tr("The file {} does not exist. Has it been moved or deleted?").format(project))
|
||||
LOGGER.warning("The file {} does not exist. Has it been moved or deleted?".format(project))
|
||||
F.statusMessage(
|
||||
self.tr("The file {} does not exist. Has it been moved or deleted?").format(project), importance=3)
|
||||
return
|
||||
|
@ -850,7 +853,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
# No UI feedback here as this code path indicates a race condition that happens
|
||||
# after the user has already closed the project through some way. But in that
|
||||
# scenario, this code should not be reachable to begin with.
|
||||
print("Bug: there is no current project to save.")
|
||||
LOGGER.error("There is no current project to save.")
|
||||
return
|
||||
|
||||
r = loadSave.saveProject() # version=0
|
||||
|
@ -861,12 +864,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
feedback = self.tr("Project {} saved.").format(projectName)
|
||||
F.statusMessage(feedback, importance=0)
|
||||
LOGGER.info("Project {} saved.".format(projectName))
|
||||
else:
|
||||
feedback = self.tr("WARNING: Project {} not saved.").format(projectName)
|
||||
F.statusMessage(feedback, importance=3)
|
||||
|
||||
# Giving some feedback in console
|
||||
print(feedback)
|
||||
LOGGER.warning("Project {} not saved.".format(projectName))
|
||||
|
||||
def loadEmptyDatas(self):
|
||||
self.mdlFlatData = QStandardItemModel(self)
|
||||
|
@ -883,13 +885,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
# Giving some feedback
|
||||
if not errors:
|
||||
print(self.tr("Project {} loaded.").format(project))
|
||||
LOGGER.info("Project {} loaded.".format(project))
|
||||
F.statusMessage(
|
||||
self.tr("Project {} loaded.").format(project), 2000)
|
||||
else:
|
||||
print(self.tr("Project {} loaded with some errors:").format(project))
|
||||
LOGGER.error("Project {} loaded with some errors:".format(project))
|
||||
for e in errors:
|
||||
print(self.tr(" * {} wasn't found in project file.").format(e))
|
||||
LOGGER.error(" * {} wasn't found in project file.".format(e))
|
||||
F.statusMessage(
|
||||
self.tr("Project {} loaded with some errors.").format(project), 5000, importance = 3)
|
||||
|
||||
|
@ -1525,7 +1527,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.menuView.addMenu(self.menuMode)
|
||||
self.menuView.addSeparator()
|
||||
|
||||
# print("Generating menus with", settings.viewSettings)
|
||||
# LOGGER.debug("Generating menus with %s.", settings.viewSettings)
|
||||
|
||||
for mnu, mnud, icon in menus:
|
||||
m = QMenu(mnu, self.menuView)
|
||||
|
@ -1619,7 +1621,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
warning2 = self.tr("PyQt {} and Qt {} are in use.").format(qVersion(), PYQT_VERSION_STR)
|
||||
|
||||
# Don't translate for debug log.
|
||||
print("WARNING:", warning1, warning2)
|
||||
LOGGER.warning(warning1)
|
||||
LOGGER.warning(warning2)
|
||||
|
||||
msg = QMessageBox(QMessageBox.Warning,
|
||||
self.tr("Proceed with import at your own risk"),
|
||||
|
|
|
@ -13,6 +13,8 @@ import re
|
|||
|
||||
from manuskript import enums
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class abstractItem():
|
||||
|
||||
|
@ -209,7 +211,7 @@ class abstractItem():
|
|||
self.IDs = self.listAllIDs()
|
||||
|
||||
if max([self.IDs.count(i) for i in self.IDs if i]) != 1:
|
||||
print("WARNING ! There are some items with same IDs:", [i for i in self.IDs if i and self.IDs.count(i) != 1])
|
||||
LOGGER.warning("There are some items with overlapping IDs: %s", [i for i in self.IDs if i and self.IDs.count(i) != 1])
|
||||
|
||||
def checkChildren(item):
|
||||
for c in item.children():
|
||||
|
|
|
@ -26,6 +26,8 @@ except:
|
|||
pass
|
||||
import time, os
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class abstractModel(QAbstractItemModel):
|
||||
"""
|
||||
|
@ -74,7 +76,7 @@ class abstractModel(QAbstractItemModel):
|
|||
if len(parent.children()) == 0:
|
||||
return None
|
||||
|
||||
# print(item.title(), [i.title() for i in parent.children()])
|
||||
#LOGGER.debug("%s: %s", item.title(), [i.title() for i in parent.children()])
|
||||
|
||||
row = parent.children().index(item)
|
||||
col = column
|
||||
|
@ -168,7 +170,7 @@ class abstractModel(QAbstractItemModel):
|
|||
|
||||
# self.dataChanged.emit(index.sibling(index.row(), 0),
|
||||
# index.sibling(index.row(), max([i.value for i in Outline])))
|
||||
# print("Model emit", index.row(), index.column())
|
||||
# LOGGER.debug("Model dataChanged emit: %s, %s", index.row(), index.column())
|
||||
self.dataChanged.emit(index, index)
|
||||
|
||||
if index.column() == Outline.type:
|
||||
|
|
|
@ -23,6 +23,8 @@ except:
|
|||
# number formatting
|
||||
pass
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class outlineItem(abstractItem, searchableItem):
|
||||
|
||||
|
@ -382,7 +384,7 @@ class outlineItem(abstractItem, searchableItem):
|
|||
searchIn = character.name()
|
||||
else:
|
||||
searchIn = ""
|
||||
print("Character POV not found:", self.POV())
|
||||
LOGGER.error("Character POV not found: %s", self.POV())
|
||||
|
||||
elif c == self.enum.status:
|
||||
searchIn = mainWindow.mdlStatus.item(F.toInt(self.status()), 0).text()
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
import re
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
###############################################################################
|
||||
# SHORT REFERENCES
|
||||
###############################################################################
|
||||
|
@ -627,7 +630,7 @@ def open(ref):
|
|||
mw.lstCharacters.setCurrentItem(item)
|
||||
return True
|
||||
|
||||
print("Error: Ref {} not found".format(ref))
|
||||
LOGGER.error("Character reference {} not found.".format(ref))
|
||||
return False
|
||||
|
||||
elif _type == TextLetter:
|
||||
|
@ -639,7 +642,7 @@ def open(ref):
|
|||
mw.mainEditor.setCurrentModelIndex(index, newTab=True)
|
||||
return True
|
||||
else:
|
||||
print("Ref not found")
|
||||
LOGGER.error("Text reference {} not found.".format(ref))
|
||||
return False
|
||||
|
||||
elif _type == PlotLetter:
|
||||
|
@ -651,7 +654,7 @@ def open(ref):
|
|||
mw.lstPlots.setCurrentItem(item)
|
||||
return True
|
||||
|
||||
print("Ref not found")
|
||||
LOGGER.error("Plot reference {} not found.".format(ref))
|
||||
return False
|
||||
|
||||
elif _type == WorldLetter:
|
||||
|
@ -664,8 +667,8 @@ def open(ref):
|
|||
mw.mdlWorld.indexFromItem(item))
|
||||
return True
|
||||
|
||||
print("Ref not found")
|
||||
LOGGER.error("World reference {} not found.".format(ref))
|
||||
return False
|
||||
|
||||
print("Ref not implemented")
|
||||
LOGGER.error("Unable to identify reference type: {}.".format(ref))
|
||||
return False
|
||||
|
|
|
@ -8,6 +8,9 @@ from PyQt5.QtWidgets import qApp
|
|||
|
||||
from manuskript.enums import Outline
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# TODO: move some/all of those settings to application settings and not project settings
|
||||
# in order to allow a shared project between several writers
|
||||
|
||||
|
@ -187,7 +190,7 @@ def load(string, fromString=False, protocol=None):
|
|||
allSettings = pickle.load(f)
|
||||
|
||||
except:
|
||||
print("{} doesn't exist, cannot load settings.".format(string))
|
||||
LOGGER.error("Cannot load settings, {} does not exist.".format(string))
|
||||
return
|
||||
else:
|
||||
if protocol == 0:
|
||||
|
|
|
@ -6,6 +6,8 @@ from PyQt5.QtWidgets import QSizePolicy, QGroupBox, QWidget, QStylePainter, QSty
|
|||
QStyle, QStyleOptionFrame, QStyleOptionFocusRect
|
||||
from manuskript.ui import style as S
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class collapsibleGroupBox(QGroupBox):
|
||||
def __init__(self, parent=None):
|
||||
|
@ -25,7 +27,7 @@ class collapsibleGroupBox(QGroupBox):
|
|||
self.tempWidget.setLayout(self.layout())
|
||||
# Set empty layout
|
||||
l = QVBoxLayout()
|
||||
# print(l.contentsMargins().left(), l.contentsMargins().bottom(), l.contentsMargins().top(), )
|
||||
# LOGGER.debug("Bounds: %s, %s, %s, %s", l.contentsMargins().left(), l.contentsMargins().bottom(), l.contentsMargins().top(), l.contentsMargins().right())
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
self.setLayout(l)
|
||||
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
|
||||
|
|
|
@ -6,6 +6,8 @@ import re
|
|||
from PyQt5.QtCore import QRegExp
|
||||
from PyQt5.QtGui import QTextCursor
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def MDFormatSelection(editor, style):
|
||||
"""
|
||||
|
@ -15,5 +17,5 @@ def MDFormatSelection(editor, style):
|
|||
1: italic
|
||||
2: code
|
||||
"""
|
||||
print("Formatting:", style, " (Unimplemented yet !)")
|
||||
LOGGER.error("Formatting: %s (Not implemented!)", style)
|
||||
# FIXME
|
|
@ -19,6 +19,8 @@ from manuskript.ui.editors.themes import loadThemeDatas
|
|||
from manuskript.ui.views.MDEditView import MDEditView
|
||||
from manuskript.functions import Spellchecker
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class fullScreenEditor(QWidget):
|
||||
def __init__(self, index, parent=None, screenNumber=None):
|
||||
|
@ -177,7 +179,7 @@ class fullScreenEditor(QWidget):
|
|||
# self.show()
|
||||
|
||||
def __del__(self):
|
||||
# print("Leaving fullScreenEditor via Destructor event", flush=True)
|
||||
LOGGER.debug("Leaving fullScreenEditor via Destructor event.")
|
||||
self.showNormal()
|
||||
self.close()
|
||||
|
||||
|
@ -286,7 +288,7 @@ class fullScreenEditor(QWidget):
|
|||
def keyPressEvent(self, event):
|
||||
if event.key() in [Qt.Key_Escape, Qt.Key_F11] and \
|
||||
not self._locked:
|
||||
# print("Leaving fullScreenEditor via keyPressEvent", flush=True)
|
||||
LOGGER.debug("Leaving fullScreenEditor via keyPressEvent.")
|
||||
self.showNormal()
|
||||
self.close()
|
||||
elif (event.modifiers() & Qt.AltModifier) and \
|
||||
|
|
|
@ -20,6 +20,9 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class mainEditor(QWidget, Ui_mainEditor):
|
||||
"""
|
||||
`mainEditor` is responsible for opening `outlineItem`s and offering information
|
||||
|
@ -389,7 +392,6 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
###############################################################################
|
||||
|
||||
def setDict(self, dict):
|
||||
print(dict)
|
||||
for w in self.allAllTabs():
|
||||
w.setDict(dict)
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ from manuskript.functions import mainWindow, appPath
|
|||
from manuskript.ui import style
|
||||
from manuskript.ui.editors.tabSplitter_ui import Ui_tabSplitter
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class tabSplitter(QWidget, Ui_tabSplitter):
|
||||
"""
|
||||
|
@ -39,7 +41,7 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
# try:
|
||||
# self.tab.setTabBarAutoHide(True)
|
||||
# except AttributeError:
|
||||
# print("Info: install Qt 5.4 or higher to use tab bar auto-hide in editor.")
|
||||
# LOGGER.info("Install Qt 5.4 or higher to use tab bar auto-hide in editor.")
|
||||
|
||||
# Button to split
|
||||
self.btnSplit = QPushButton(self)
|
||||
|
|
|
@ -12,6 +12,8 @@ import manuskript.ui.style as S
|
|||
from manuskript import settings
|
||||
from manuskript import functions as F
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class BasicHighlighter(QSyntaxHighlighter):
|
||||
def __init__(self, editor):
|
||||
|
@ -130,14 +132,14 @@ class BasicHighlighter(QSyntaxHighlighter):
|
|||
before you do any custom highlighting. Or implement doHighlightBlock.
|
||||
"""
|
||||
|
||||
#print(">", self.currentBlock().document().availableUndoSteps())
|
||||
#LOGGER.debug("undoSteps before: %s", self.currentBlock().document().availableUndoSteps())
|
||||
c = QTextCursor(self.currentBlock())
|
||||
#c.joinPreviousEditBlock()
|
||||
bf = QTextBlockFormat(self._defaultBlockFormat)
|
||||
if bf != c.blockFormat():
|
||||
c.setBlockFormat(bf)
|
||||
#c.endEditBlock()
|
||||
#print(" ", self.currentBlock().document().availableUndoSteps())
|
||||
#LOGGER.debug("undoSteps after: %s", self.currentBlock().document().availableUndoSteps())
|
||||
|
||||
# self.setFormat(0, len(text), self._defaultCharFormat)
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ from PyQt5.QtWidgets import *
|
|||
from manuskript.ui.highlighters import MarkdownState as MS
|
||||
from manuskript.ui.highlighters import MarkdownTokenType as MTT
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# This file is simply a python translation of GhostWriter's Tokenizer.
|
||||
# http://wereturtle.github.io/ghostwriter/
|
||||
# GPLV3+.
|
||||
|
@ -56,7 +59,7 @@ class HighlightTokenizer:
|
|||
self.tokens.append(token)
|
||||
|
||||
if token.type == -1:
|
||||
print("Error here", token.position, token.length)
|
||||
LOGGER.error("Token type invalid: position %s, length %s.", token.position, token.length)
|
||||
|
||||
def setState(self, state):
|
||||
self.state = state
|
||||
|
|
|
@ -14,6 +14,8 @@ from manuskript.ui.highlighters.markdownEnums import MarkdownState as MS
|
|||
from manuskript.ui.highlighters.markdownTokenizer import MarkdownTokenizer as MT
|
||||
from manuskript import functions as F
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class MDEditView(textEditView):
|
||||
|
||||
|
@ -660,10 +662,10 @@ class ImageTooltip:
|
|||
return
|
||||
else:
|
||||
# Somehow we lost track. Log what we can to hopefully figure it out.
|
||||
print("Warning: unable to match fetched data for tooltip to original request.")
|
||||
print("- Completed request:", url_key)
|
||||
print("- Status upon finishing:", reply.error(), reply.errorString())
|
||||
print("- Currently processing:", ImageTooltip.processing)
|
||||
LOGGER.warning("Unable to match fetched data for tooltip to original request.")
|
||||
LOGGER.warning("- Completed request: %s", url_key)
|
||||
LOGGER.warning("- Status upon finishing: %s, %s", reply.error(), reply.errorString())
|
||||
LOGGER.warning("- Currently processing: %s", ImageTooltip.processing)
|
||||
return
|
||||
|
||||
# Update cache with retrieved data.
|
||||
|
|
|
@ -13,7 +13,6 @@ class dndView(QAbstractItemView):
|
|||
|
||||
def dragMoveEvent(self, event):
|
||||
# return QAbstractItemView.dragMoveEvent(self, event)
|
||||
# print(a)
|
||||
if event.keyboardModifiers() & Qt.ControlModifier:
|
||||
event.setDropAction(Qt.CopyAction)
|
||||
else:
|
||||
|
|
|
@ -7,6 +7,8 @@ from manuskript.enums import Outline
|
|||
from manuskript.ui.views.propertiesView_ui import Ui_propertiesView
|
||||
from manuskript.models.characterPOVModel import characterPOVModel
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class propertiesView(QWidget, Ui_propertiesView):
|
||||
def __init__(self, parent=None):
|
||||
|
@ -39,7 +41,7 @@ class propertiesView(QWidget, Ui_propertiesView):
|
|||
def selectionChanged(self, sourceView):
|
||||
|
||||
indexes = self.getIndexes(sourceView)
|
||||
# print(indexes)
|
||||
# LOGGER.debug("selectionChanged indexes: %s", indexes)
|
||||
if len(indexes) == 0:
|
||||
self.setEnabled(False)
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ from manuskript.functions import Spellchecker
|
|||
from manuskript.models.characterModel import Character, CharacterInfo
|
||||
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class textEditView(QTextEdit):
|
||||
def __init__(self, parent=None, index=None, html=None, spellcheck=None,
|
||||
highlighting=False, dict="", autoResize=False):
|
||||
|
@ -58,13 +61,13 @@ class textEditView(QTextEdit):
|
|||
self.updateTimer.setInterval(500)
|
||||
self.updateTimer.setSingleShot(True)
|
||||
self.updateTimer.timeout.connect(self.submit)
|
||||
# self.updateTimer.timeout.connect(lambda: print("Timeout"))
|
||||
# self.updateTimer.timeout.connect(lambda: LOGGER.debug("Timeout."))
|
||||
|
||||
self.updateTimer.stop()
|
||||
self.document().contentsChanged.connect(self.updateTimer.start, F.AUC)
|
||||
# self.document().contentsChanged.connect(lambda: print("Document changed"))
|
||||
# self.document().contentsChanged.connect(lambda: LOGGER.debug("Document changed."))
|
||||
|
||||
# self.document().contentsChanged.connect(lambda: print(self.objectName(), "Contents changed"))
|
||||
# self.document().contentsChanged.connect(lambda: LOGGER.debug("Contents changed: %s", self.objectName()))
|
||||
|
||||
self.setEnabled(False)
|
||||
|
||||
|
@ -248,7 +251,7 @@ class textEditView(QTextEdit):
|
|||
if topLeft.parent() != self._index.parent():
|
||||
return
|
||||
|
||||
# print("Model changed: ({}:{}), ({}:{}/{}), ({}:{}) for {} of {}".format(
|
||||
# LOGGER.debug("Model changed: ({}:{}), ({}:{}/{}), ({}:{}) for {} of {}".format(
|
||||
# topLeft.row(), topLeft.column(),
|
||||
# self._index.row(), self._index.row(), self._column,
|
||||
# bottomRight.row(), bottomRight.column(),
|
||||
|
@ -278,11 +281,11 @@ class textEditView(QTextEdit):
|
|||
def updateText(self):
|
||||
self._updating.lock()
|
||||
|
||||
# print("Updating", self.objectName())
|
||||
# LOGGER.debug("Updating %s", self.objectName())
|
||||
if self._index:
|
||||
self.disconnectDocument()
|
||||
if self.toPlainText() != F.toString(self._index.data()):
|
||||
# print(" Updating plaintext")
|
||||
# LOGGER.debug(" Updating plaintext")
|
||||
self.document().setPlainText(F.toString(self._index.data()))
|
||||
self.reconnectDocument()
|
||||
|
||||
|
@ -319,18 +322,18 @@ class textEditView(QTextEdit):
|
|||
text = self.toPlainText()
|
||||
self._updating.unlock()
|
||||
|
||||
# print("Submitting", self.objectName())
|
||||
# LOGGER.debug("Submitting %s", self.objectName())
|
||||
if self._index and self._index.isValid():
|
||||
# item = self._index.internalPointer()
|
||||
if text != self._index.data():
|
||||
# print(" Submitting plain text")
|
||||
# LOGGER.debug(" Submitting plain text")
|
||||
self._model.setData(QModelIndex(self._index), text)
|
||||
|
||||
elif self._indexes:
|
||||
for i in self._indexes:
|
||||
item = i.internalPointer()
|
||||
if text != F.toString(item.data(self._column)):
|
||||
print("Submitting many indexes")
|
||||
LOGGER.debug("Submitting many indexes")
|
||||
self._model.setData(i, text)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
|
@ -484,7 +487,7 @@ class textEditView(QTextEdit):
|
|||
|
||||
def newCharacter(self):
|
||||
text = self.sender().data()
|
||||
print("new character!", text)
|
||||
LOGGER.debug(f'New character: {text}')
|
||||
# switch to character page
|
||||
mw = F.mainWindow()
|
||||
mw.tabMain.setCurrentIndex(mw.TabPersos)
|
||||
|
@ -496,7 +499,7 @@ class textEditView(QTextEdit):
|
|||
|
||||
def newPlotItem(self):
|
||||
text = self.sender().data()
|
||||
print("new plot item!", text)
|
||||
LOGGER.debug(f'New plot item: {text}')
|
||||
# switch to plot page
|
||||
mw = F.mainWindow()
|
||||
mw.tabMain.setCurrentIndex(mw.TabPlots)
|
||||
|
@ -509,7 +512,7 @@ class textEditView(QTextEdit):
|
|||
|
||||
def newWorldItem(self):
|
||||
text = self.sender().data()
|
||||
print("new world item!", text)
|
||||
LOGGER.debug(f'New world item: {text}')
|
||||
mw = F.mainWindow()
|
||||
mw.tabMain.setCurrentIndex(mw.TabWorld)
|
||||
item = mw.mdlWorld.addItem(title=text)
|
||||
|
|
|
@ -21,6 +21,9 @@ from manuskript.models.worldModel import worldModel
|
|||
from manuskript.ui.welcome_ui import Ui_welcome
|
||||
from manuskript.ui import style as S
|
||||
|
||||
import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
except:
|
||||
|
@ -57,8 +60,7 @@ class welcome(QWidget, Ui_welcome):
|
|||
sttgs = QSettings()
|
||||
lastDirectory = sttgs.value("lastAccessedDirectory", defaultValue=".", type=str)
|
||||
if lastDirectory != '.':
|
||||
print(qApp.translate("lastAccessedDirectoryInfo", "Last accessed directory \"{}\" loaded.").format(
|
||||
lastDirectory))
|
||||
LOGGER.info("Last accessed directory \"{}\" loaded.".format(lastDirectory))
|
||||
return lastDirectory
|
||||
|
||||
def setLastAccessedDirectory(self, dir):
|
||||
|
|
Loading…
Reference in a new issue