Fixed all Python syntax warnings

This commit is contained in:
TheJackiMonster 2021-02-21 23:45:34 +01:00
parent 6731051e92
commit 12be4c3a3d
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
34 changed files with 103 additions and 102 deletions

View file

@ -26,7 +26,7 @@ class markdownConverter(abstractConverter):
@classmethod
def isValid(self):
return MD is not None
return MD != None
@classmethod
def convert(self, markdown):

View file

@ -24,7 +24,7 @@ class HTML(markdown):
exportDefaultSuffix = ".html"
def isValid(self):
return MD is not None
return MD != None
def settingsWidget(self):
w = markdownSettings(self)

View file

@ -51,10 +51,10 @@ class plainText(basicFormat):
def getExportFilename(self, settingsWidget, varName=None, filter=None):
if varName is None:
if varName == None:
varName = self.exportVarName
if filter is None:
if filter == None:
filter = self.exportFilter
settings = settingsWidget.getSettings()

View file

@ -31,7 +31,7 @@ class PDF(abstractOutput):
def isValid(self):
path = shutil.which("pdflatex") or shutil.which("xelatex")
return path is not None
return path != None
def output(self, settingsWidget, outputfile=None):
args = settingsWidget.runnableSettings()

View file

@ -75,7 +75,7 @@ class pandocSetting:
"""Return whether the specific setting is active with the given format."""
# Empty formats means all
if self.formats is "":
if self.formats == "":
return True
# "html" in "html markdown latex"

View file

@ -111,7 +111,7 @@ class Spellchecker:
(lib, name) = values
try:
d = Spellchecker.dictionaries.get(dictionary, None)
if d is None:
if d == None:
for impl in Spellchecker.implementations:
if impl.isInstalled() and lib == impl.getLibraryName():
d = impl(name)
@ -267,7 +267,7 @@ class EnchantDictionary(BasicDictionary):
@staticmethod
def isInstalled():
return enchant is not None
return enchant != None
@staticmethod
def availableDictionaries():
@ -284,9 +284,9 @@ class EnchantDictionary(BasicDictionary):
if default_locale and not enchant.dict_exists(default_locale):
default_locale = None
if default_locale is None:
if default_locale == None:
default_locale = QLocale.system().name()
if default_locale is None:
if default_locale == None:
default_locale = self.availableDictionaries()[0]
return default_locale
@ -330,7 +330,7 @@ class PySpellcheckerDictionary(BasicDictionary):
@staticmethod
def isInstalled():
return pyspellchecker is not None
return pyspellchecker != None
@staticmethod
def availableDictionaries():
@ -350,7 +350,7 @@ class PySpellcheckerDictionary(BasicDictionary):
default_locale = QLocale.system().name()
if default_locale:
default_locale = default_locale[0:2]
if default_locale is None:
if default_locale == None:
default_locale = "en"
return default_locale
@ -415,7 +415,7 @@ class SymSpellDictionary(BasicDictionary):
@staticmethod
def isInstalled():
return symspellpy is not None
return symspellpy != None
@classmethod
def availableDictionaries(cls):
@ -524,7 +524,7 @@ class LanguageToolDictionary(BasicDictionary):
@staticmethod
def isInstalled():
if languagetool is not None:
if languagetool != None:
# This check, if Java is installed, is necessary to
# make sure LanguageTool can be run without problems.
@ -550,9 +550,9 @@ class LanguageToolDictionary(BasicDictionary):
if default_locale and not default_locale in languagetool.get_languages():
default_locale = None
if default_locale is None:
if default_locale == None:
default_locale = QLocale.system().name()
if default_locale is None:
if default_locale == None:
default_locale = self.availableDictionaries()[0]
return default_locale

View file

@ -47,7 +47,7 @@ class mindMapImporter(abstractImporter):
node = root.find("node")
items = []
if node is not None:
if node != None:
items.extend(self.parseItems(node, parentItem))
ret = True
@ -97,7 +97,7 @@ class mindMapImporter(abstractImporter):
# Rich text content
content = ""
content = underElement.find("richcontent")
if content is not None:
if content != None:
# In Freemind, can be note or node
# Note: it's a note
# Node: it's the title of the node, in rich text
@ -130,7 +130,7 @@ class mindMapImporter(abstractImporter):
children = underElement.findall('node')
# Process children
if children is not None and len(children) > 0:
if children != None and len(children) > 0:
for c in children:
items.extend(self.parseItems(c, item))

View file

@ -52,10 +52,10 @@ class opmlImporter(abstractImporter):
bodyNode = opmlNode.find("body")
items = []
if bodyNode is not None:
if bodyNode != None:
outlineEls = bodyNode.findall("outline")
if outlineEls is not None:
if outlineEls != None:
for element in outlineEls:
items.extend(cls.parseItems(element, parentItem))
ret = True
@ -74,19 +74,20 @@ class opmlImporter(abstractImporter):
def parseItems(cls, underElement, parentItem=None):
items = []
title = underElement.get('text')
if title is not None:
if title != None:
card = outlineItem(parent=parentItem, title=title)
items.append(card)
body = ""
note = underElement.get('_note')
if note is not None and not cls.isWhitespaceOnly(note):
if note != None and not cls.isWhitespaceOnly(note):
#body = cls.restoreNewLines(note)
body = note
children = underElement.findall('outline')
if children is not None and len(children) > 0:
if children != None and len(children) > 0:
for el in children:
items.extend(cls.parseItems(el, card))
else:
@ -121,4 +122,4 @@ class opmlImporter(abstractImporter):
s = cls.restoreNewLines(inString)
s = ''.join(s.split())
return len(s) is 0
return len(s) == 0

View file

@ -38,7 +38,7 @@ class pandocImporter(abstractImporter):
r = pandocExporter().run(args)
if r is None:
if r == None:
return None
if formatTo == "opml":

View file

@ -107,7 +107,7 @@ def saveProject(zip=None):
settings.
@return: True if successful, False otherwise.
"""
if zip is None:
if zip == None:
zip = settings.saveToZip
log("\n\nSaving to:", "zip" if zip else "folder")
@ -124,7 +124,7 @@ def saveProject(zip=None):
project = mw.currentProject
# Sanity check (see PR-583): make sure we actually have a current project.
if project is None:
if project == None:
print("Error: cannot save project because there is no current project in the UI.")
return False
@ -198,7 +198,7 @@ def saveProject(zip=None):
# We skip the first row, which is empty and transparent
for i in range(1, mdl.rowCount()):
color = ""
if mdl.data(mdl.index(i, 0), Qt.DecorationRole) is not None:
if mdl.data(mdl.index(i, 0), Qt.DecorationRole) != None:
color = iconColor(mdl.data(mdl.index(i, 0), Qt.DecorationRole)).name(QColor.HexRgb)
color = color if color != "#ff000000" else "#00000000"
@ -901,7 +901,7 @@ def addTextItems(mdl, odict, parent=None):
@param odict: OrderedDict
@return: nothing
"""
if parent is None:
if parent == None:
parent = mdl.rootItem
for k in odict:

View file

@ -101,7 +101,7 @@ def prepare(tests=False):
def respectSystemDarkThemeSetting():
"""Adjusts the Qt theme to match the OS 'dark theme' setting configured by the user."""
if platform.system() is not 'Windows':
if platform.system() != 'Windows':
return
# Basic Windows 10 Dark Theme support.
@ -168,7 +168,7 @@ def prepare(tests=False):
def launch(app, MW = None):
if MW is None:
if MW == None:
from manuskript.functions import mainWindow
MW = mainWindow()
@ -176,7 +176,7 @@ def launch(app, MW = None):
# Support for IPython Jupyter QT Console as a debugging aid.
# Last argument must be --console to enable it
# Code reference :
# Code reference :
# https://github.com/ipython/ipykernel/blob/master/examples/embedding/ipkernel_qtapp.py
# https://github.com/ipython/ipykernel/blob/master/examples/embedding/internal_ipkernel.py
if len(sys.argv) > 1 and sys.argv[-1] == "--console":
@ -188,7 +188,7 @@ def launch(app, MW = None):
# Create IPython kernel within our application
kernel = IPKernelApp.instance()
# Initialize it and use matplotlib for main event loop integration with QT
kernel.initialize(['python', '--matplotlib=qt'])

View file

@ -270,7 +270,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.mainEditor
]
while new is not None:
while new != None:
if new in targets:
self._lastFocus = new
break
@ -838,7 +838,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# risk a scenario where the timer somehow triggers a new save while saving.
self.saveTimerNoChanges.stop()
if self.currentProject is None:
if self.currentProject == None:
# 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.
@ -1095,7 +1095,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# disconnect only removes one connection at a time.
while True:
try:
if oldHandler is not None:
if oldHandler != None:
signal.disconnect(oldHandler)
else:
signal.disconnect()
@ -1375,7 +1375,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
dictionaries = Spellchecker.availableDictionaries()
# Set first run dictionary
if settings.dict is None:
if settings.dict == None:
settings.dict = Spellchecker.getDefaultDictionary()
# Check if project dict is unavailable on this machine
@ -1586,7 +1586,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
w.cmbPOV.setVisible(val)
# POV in outline view
if val is None and Outline.POV in settings.outlineViewColumns:
if val == None and Outline.POV in settings.outlineViewColumns:
settings.outlineViewColumns.remove(Outline.POV)
from manuskript.ui.views.outlineView import outlineView

View file

@ -39,7 +39,7 @@ class abstractItem():
self._data[self.enum.title] = title
self._data[self.enum.type] = _type
if xml is not None:
if xml != None:
self.setFromXML(xml)
if ID:

View file

@ -131,7 +131,7 @@ class abstractModel(QAbstractItemModel):
# Check whether the parent is the root, or is otherwise invalid.
# That is to say: no parent or the parent lacks a parent.
if (parentItem == self.rootItem) or \
(parentItem is None) or (parentItem.parent() is None):
(parentItem == None) or (parentItem.parent() == None):
return QModelIndex()
return self.createIndex(parentItem.row(), 0, parentItem)
@ -283,7 +283,7 @@ class abstractModel(QAbstractItemModel):
# # Gets encoded mime data to retrieve the item
items = self.decodeMimeData(data)
if items is None:
if items == None:
return False
# We check if parent is not a child of one of the items
@ -321,7 +321,7 @@ class abstractModel(QAbstractItemModel):
return None
encodedData = bytes(data.data("application/xml")).decode()
root = ET.XML(encodedData)
if root is None:
if root == None:
return None
if root.tag != "outlineItems":
@ -381,7 +381,7 @@ class abstractModel(QAbstractItemModel):
items = self.decodeMimeData(data)
if items is None:
if items == None:
return False
if column > 0:

View file

@ -153,7 +153,7 @@ class characterModel(QAbstractItemModel):
return r
def getCharacterByID(self, ID):
if ID is not None:
if ID != None:
ID = str(ID)
for c in self.characters:
if c.ID() == ID:

View file

@ -187,7 +187,7 @@ def infos(ref):
elif _type == CharacterLetter:
m = mainWindow().mdlCharacter
c = m.getCharacterByID(int(_ref))
if c is None:
if c == None:
return qApp.translate("references", "Unknown reference: {}.").format(ref)
index = c.index()

View file

@ -189,7 +189,7 @@ class worldModel(QStandardItemModel):
for index in indexes:
item = self.itemFromIndex(index)
parent = item.parent()
if parent is None:
if parent == None:
parent = self.invisibleRootItem()
row_indexes.append((parent, item.row()))

View file

@ -12,7 +12,7 @@ def MW():
"""
from manuskript import functions as F
MW = F.mainWindow()
assert MW is not None
assert MW != None
assert MW == F.MW
return MW
@ -23,7 +23,7 @@ def MWNoProject(MW):
Take the MainWindow and close andy possibly open project.
"""
MW.closeProject()
assert MW.currentProject is None
assert MW.currentProject == None
return MW
@pytest.fixture
@ -35,9 +35,9 @@ def MWEmptyProject(MW):
tf = tempfile.NamedTemporaryFile(suffix=".msk")
MW.closeProject()
assert MW.currentProject is None
assert MW.currentProject == None
MW.welcome.createFile(tf.name, overwrite=True)
assert MW.currentProject is not None
assert MW.currentProject != None
return MW
# If using with: @pytest.fixture(scope='session', autouse=True)
@ -67,6 +67,6 @@ def MWSampleProject(MW):
shutil.copyfile(src, tf.name)
shutil.copytree(src[:-4], tf.name[:-4])
MW.loadProject(tf.name)
assert MW.currentProject is not None
assert MW.currentProject != None
return MW

View file

@ -130,9 +130,9 @@ def test_modelStuff(outlineModelBasic):
folder.setModel(k)
assert folder.columnCount() == len(folder.enum)
text1 = text2.copy()
assert text1.ID() is None
assert text1.ID() == None
folder.appendChild(text1)
assert text1.ID() is not None
assert text1.ID() != None
assert folder.childCountRecursive() == 2
assert text1.path() == "Folder > Text"
assert len(text1.pathID()) == 2

View file

@ -39,7 +39,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.plotReference(plotID))
assert "Not a ref" in Ref.infos("<invalid>")
assert "Unknown" in Ref.infos(Ref.plotReference("999"))
assert Ref.shortInfos(Ref.plotReference(plotID)) is not None
assert Ref.shortInfos(Ref.plotReference(plotID)) != None
assert Ref.shortInfos(Ref.plotReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
@ -50,7 +50,7 @@ def test_references(MWSampleProject):
charID = IDs[0]
assert "\n" in Ref.infos(Ref.characterReference(charID))
assert "Unknown" in Ref.infos(Ref.characterReference("999"))
assert Ref.shortInfos(Ref.characterReference(charID)) is not None
assert Ref.shortInfos(Ref.characterReference(charID)) != None
assert Ref.shortInfos(Ref.characterReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
@ -62,7 +62,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.textReference(textID))
assert "Unknown" in Ref.infos(Ref.textReference("999"))
assert Ref.shortInfos(Ref.textReference(textID)) is not None
assert Ref.shortInfos(Ref.textReference(textID)) != None
assert Ref.shortInfos(Ref.textReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
@ -73,7 +73,7 @@ def test_references(MWSampleProject):
assert "\n" in Ref.infos(Ref.worldReference(worldID))
assert "Unknown" in Ref.infos(Ref.worldReference("999"))
assert Ref.shortInfos(Ref.worldReference(worldID)) is not None
assert Ref.shortInfos(Ref.worldReference(worldID)) != None
assert Ref.shortInfos(Ref.worldReference("999")) == None
assert Ref.shortInfos("<invalidref>") == -1
@ -84,9 +84,9 @@ def test_references(MWSampleProject):
# Titles
for ref in refs:
assert Ref.title(ref) is not None
assert Ref.title("<invalid>") is None
assert Ref.title(Ref.plotReference("999")) is None
assert Ref.title(ref) != None
assert Ref.title("<invalid>") == None
assert Ref.title(Ref.plotReference("999")) == None
# Other stuff
assert Ref.type(Ref.plotReference(plotID)) == Ref.PlotLetter
@ -94,10 +94,10 @@ def test_references(MWSampleProject):
assert "Unknown" in Ref.tooltip(Ref.worldReference("999"))
assert "Not a ref" in Ref.tooltip("<invalid>")
for ref in refs:
assert Ref.tooltip(ref) is not None
assert Ref.tooltip(ref) != None
# Links
assert Ref.refToLink("<invalid>") is None
assert Ref.refToLink("<invalid>") == None
assert Ref.refToLink(Ref.plotReference("999")) == Ref.plotReference("999")
assert Ref.refToLink(Ref.characterReference("999")) == Ref.characterReference("999")
assert Ref.refToLink(Ref.textReference("999")) == Ref.textReference("999")
@ -106,7 +106,7 @@ def test_references(MWSampleProject):
assert "<a href" in Ref.refToLink(ref)
# Open
assert Ref.open("<invalid>") is None
assert Ref.open("<invalid>") == None
assert Ref.open(Ref.plotReference("999")) == False
assert Ref.open(Ref.characterReference("999")) == False
assert Ref.open(Ref.textReference("999")) == False

View file

@ -46,8 +46,8 @@ def test_several():
assert F.iconColor(icon).name().lower() == "#ff0000"
# themeIcon
assert F.themeIcon("text") is not None
assert F.themeIcon("nonexistingname") is not None
assert F.themeIcon("text") != None
assert F.themeIcon("nonexistingname") != None
# randomColor
c1 = F.randomColor()
@ -75,10 +75,10 @@ def test_outlineItemColors():
def test_paths():
assert F.appPath() is not None
assert F.writablePath is not None
assert F.appPath() != None
assert F.writablePath != None
assert len(F.allPaths("suffix")) == 2
assert F.tempFile("yop") is not None
assert F.tempFile("yop") != None
f = F.findBackground("spacedreams.jpg")
assert "resources/backgrounds/spacedreams.jpg" in f
assert len(F.customIcons()) > 1
@ -87,8 +87,8 @@ def test_mainWindow():
from PyQt5.QtWidgets import QWidget, QLCDNumber
assert F.mainWindow() is not None
assert F.MW is not None
assert F.mainWindow() != None
assert F.MW != None
F.statusMessage("Test")
F.printObjects()

View file

@ -55,7 +55,7 @@ def test_general(MWSampleProject):
state = settings()
assert chk.isChecked() == state
chk.setChecked(not state)
assert chk.isChecked() is not state
assert chk.isChecked() != state
# Loading and Saving
SW.txtAutoSave.setText("0")
@ -86,7 +86,7 @@ def test_general(MWSampleProject):
SW.chkOutlineTitle.setChecked(Qt.Unchecked)
SW.chkOutlineTitle.setChecked(Qt.Checked)
# Can't test because of the dialog
# assert SW.setCorkColor() is None
# assert SW.setCorkColor() == None
SW.sldTreeIconSize.setValue(SW.sldTreeIconSize.value() + 1)
SW.rdoCorkNewStyle.toggled.emit(True)
SW.cmbCorkImage.currentIndexChanged.emit(0)
@ -98,7 +98,7 @@ def test_general(MWSampleProject):
# Test editor
switchCheckBoxAndAssert(SW.chkEditorBackgroundTransparent,
lambda: S.textEditor["backgroundTransparent"])
assert SW.restoreEditorColors() is None
assert SW.restoreEditorColors() == None
switchCheckBoxAndAssert(SW.chkEditorNoBlinking,
lambda: S.textEditor["cursorNotBlinking"])
# Twice on purpose: set and restore
@ -108,7 +108,7 @@ def test_general(MWSampleProject):
SW.updateAllWidgets()
# Labels
assert SW.updateLabelColor(MW.mdlLabels.item(1).index()) is None
assert SW.updateLabelColor(MW.mdlLabels.item(1).index()) == None
rc = MW.mdlLabels.rowCount()
SW.addLabel()
SW.lstLabels.setCurrentIndex(
@ -150,7 +150,7 @@ def test_general(MWSampleProject):
for i in range(4):
SW.updateLineSpacing(i)
SW.updateUIFromTheme() # No time to wait on timer
assert SW._editingTheme is not None
assert SW._editingTheme != None
SW.resize(SW.geometry().size()) # resizeEvent
#TODO: other edit test (see SW.loadTheme
SW.saveTheme()

View file

@ -96,7 +96,7 @@ class collapsibleDockWidgets(QToolBar):
def setCurrentGroup(self, group):
self.currentGroup = group
for btn, action, widget, grp in self.otherWidgets:
if not grp == group or grp is None:
if not grp == group or grp == None:
action.setVisible(False)
else:
action.setVisible(True)

View file

@ -8,7 +8,7 @@ class blockUserData(QTextBlockUserData):
def getUserData(block):
"""Returns userData if it exists, or a blank one."""
data = block.userData()
if data is None:
if data == None:
data = blockUserData()
return data

View file

@ -338,8 +338,8 @@ class fullScreenEditor(QWidget):
item = self._index.internalPointer()
previousItem = self.previousTextItem(item)
nextItem = self.nextTextItem(item)
self.btnPrevious.setEnabled(previousItem is not None)
self.btnNext.setEnabled(nextItem is not None)
self.btnPrevious.setEnabled(previousItem != None)
self.btnNext.setEnabled(nextItem != None)
self.wPath.setItem(item)
def updateStatusBar(self):
@ -572,11 +572,11 @@ class myPanel(QWidget):
def addWidgetSetting(self, label, config_name, widgets):
setting = (label, config_name, widgets)
self._settings.append(setting)
if settings.fullscreenSettings.get(config_name, None) is not None:
if settings.fullscreenSettings.get(config_name, None) != None:
self._setSettingValue(setting, settings.fullscreenSettings[config_name])
def addSetting(self, label, config_name, default=True):
if settings.fullscreenSettings.get(config_name, None) is None:
if settings.fullscreenSettings.get(config_name, None) == None:
self._setConfig(config_name, default)
self.addWidgetSetting(label, config_name, None)
@ -651,7 +651,7 @@ class myPath(QWidget):
if i == item:
a.setIcon(QIcon.fromTheme("stock_yes"))
a.setEnabled(False)
elif self.editor.firstTextItem(i) is None:
elif self.editor.firstTextItem(i) == None:
a.setEnabled(False)
else:
a.triggered.connect(gen_cb(i))

View file

@ -105,6 +105,6 @@ class locker(QWidget, Ui_locker):
text))
# Word locked
elif self._target is not None:
elif self._target != None:
self.btnLock.setText(self.tr("{} words remaining").format(
self._target - self._words))

View file

@ -120,7 +120,7 @@ class mainEditor(QWidget, Ui_mainEditor):
return self.tabSplitter.tab
def currentEditor(self, tabWidget=None):
if tabWidget is None:
if tabWidget == None:
tabWidget = self.currentTabWidget()
return tabWidget.currentWidget()
# return self.tab.currentWidget()
@ -153,7 +153,7 @@ class mainEditor(QWidget, Ui_mainEditor):
def allTabs(self, tabWidget=None):
"""Returns all the tabs from the given tabWidget. If tabWidget is None, from the current tabWidget."""
if tabWidget is None:
if tabWidget == None:
tabWidget = self.currentTabWidget()
return [tabWidget.widget(i) for i in range(tabWidget.count())]
@ -205,7 +205,7 @@ class mainEditor(QWidget, Ui_mainEditor):
title = self.getIndexTitle(index)
if tabWidget is None:
if tabWidget == None:
tabWidget = self.currentTabWidget()
# Checking if tab is already opened

View file

@ -145,8 +145,8 @@ class tabSplitter(QWidget, Ui_tabSplitter):
def split(self, toggled=None, state=None):
if state is None and self.splitState == 0 or state == 1:
if self.secondTab is None:
if state == None and self.splitState == 0 or state == 1:
if self.secondTab == None:
self.addSecondTab()
self.splitState = 1
@ -155,8 +155,8 @@ class tabSplitter(QWidget, Ui_tabSplitter):
self.btnSplit.setIcon(QIcon.fromTheme("split-vertical"))
self.btnSplit.setToolTip(self.tr("Split horizontally"))
elif state is None and self.splitState == 1 or state == 2:
if self.secondTab is None:
elif state == None and self.splitState == 1 or state == 2:
if self.secondTab == None:
self.addSecondTab()
self.splitter.setOrientation(Qt.Vertical)
@ -212,7 +212,7 @@ class tabSplitter(QWidget, Ui_tabSplitter):
# self.btnSplit.setGeometry(QRect(0, 0, 24, 24))
def focusChanged(self, old, new):
if self.secondTab is None or new is None:
if self.secondTab == None or new == None:
return
oldFT = self.focusTab

View file

@ -713,7 +713,7 @@ class MarkdownHighlighter(BasicHighlighter):
# FIXME: TypeError: could not convert 'TextBlockData' to 'QTextBlockUserData'
# blockData = self.currentBlockUserData()
# if blockData is None:
# if blockData == None:
# blockData = TextBlockData(self.document(), self.currentBlock())
#
# self.setCurrentBlockUserData(blockData)

View file

@ -66,7 +66,7 @@ class characterTreeView(QTreeWidget):
for child in range(item.childCount()):
sub = item.child(child)
ID = sub.data(0, Qt.UserRole)
if ID is not None:
if ID != None:
# Update name
c = self._model.getCharacterByID(ID)
name = c.name()
@ -124,8 +124,8 @@ class characterTreeView(QTreeWidget):
curr_importance = 0
# check if an item is selected
if curr_item is not None:
if curr_item.parent() is None:
if curr_item != None:
if curr_item.parent() == None:
# this is a top-level category, so find its importance
# get the current text, then look up the importance level
text = curr_item.text(0)

View file

@ -31,7 +31,7 @@ class lineEditView(QLineEdit):
self._index = index
self._model = index.model()
# self.item = index.internalPointer()
if self._placeholderText is not None:
if self._placeholderText != None:
self.setPlaceholderText(self._placeholderText)
self.textEdited.connect(self.submit)
self.updateText()

View file

@ -34,7 +34,7 @@ class textEditView(QTextEdit):
self._themeData = None
self._highlighterClass = BasicHighlighter
if spellcheck is None:
if spellcheck == None:
spellcheck = settings.spellcheck
self.spellcheck = spellcheck

View file

@ -69,7 +69,7 @@ class treeView(QTreeView, dndView, outlineBasics):
return menu
def expandCurrentIndex(self, index=None):
if index is None or type(index) == bool:
if index == None or type(index) == bool:
index = self._indexesToOpen[0] # self.currentIndex()
self.expand(index)
@ -78,7 +78,7 @@ class treeView(QTreeView, dndView, outlineBasics):
self.expandCurrentIndex(index=idx)
def collapseCurrentIndex(self, index=None):
if index is None or type(index) == bool:
if index == None or type(index) == bool:
index = self._indexesToOpen[0] # self.currentIndex()
self.collapse(index)

View file

@ -371,7 +371,7 @@ class welcome(QWidget, Ui_welcome):
Qt.FindChildrenRecursively):
# Update self.template to reflect the changed name values
templateIndex = t.property("templateIndex")
if templateIndex is not None :
if templateIndex != None :
self.template[1][templateIndex] = (
self.template[1][templateIndex][0],
t.text())