From 014b970982ccf7e401bb524744a4c471ada645d0 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 7 Oct 2020 20:33:34 +0200 Subject: [PATCH] Change a few checks to use built-in features --- nw/common.py | 8 ++++---- nw/core/spellcheck.py | 7 ++----- nw/gui/doceditor.py | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nw/common.py b/nw/common.py index 2fef7874..17a8a337 100644 --- a/nw/common.py +++ b/nw/common.py @@ -203,12 +203,12 @@ def transferCase(theSource, theTarget): if len(theTarget) < 1 or len(theSource) < 1: return theResult - if theSource[0] == theSource[0].upper(): - theResult = theTarget[0].upper() + theTarget[1:] + if theSource.istitle(): + theResult = theTarget.title() - if theSource == theSource.upper(): + if theSource.isupper(): theResult = theTarget.upper() - elif theSource == theSource.lower(): + elif theSource.islower(): theResult = theTarget.lower() return theResult diff --git a/nw/core/spellcheck.py b/nw/core/spellcheck.py index d2c19784..ff338f62 100644 --- a/nw/core/spellcheck.py +++ b/nw/core/spellcheck.py @@ -291,15 +291,12 @@ class NWSpellSimple(NWSpellCheck): if len(theWord) == 0: return [] - firstUp = theWord[0] == theWord[0].upper() - theWord = theWord.lower() - - theMatches = get_close_matches(theWord, self.WORDS, n=10, cutoff=0.75) + theMatches = get_close_matches(theWord.lower(), self.WORDS, n=10, cutoff=0.75) theOptions = [] for aWord in theMatches: if len(aWord) == 0: continue - if firstUp: + if theWord[0].isupper(): aWord = aWord[0].upper() + aWord[1:] aWord = aWord.replace("'", self.mainConf.fmtApostrophe) theOptions.append(aWord) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 16683d1f..f805e5ae 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -509,7 +509,7 @@ class GuiDocEditor(QTextEdit): aLang, aName = self.theDict.describeDict() self.theParent.statusBar.setLanguage( - aLang, "%s/%s" % (self.mainConf.spellTool, aName) + aLang, "%s [%s]" % (self.mainConf.spellTool.title(), aName.title()) ) if not self.bigDoc: