summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2024-07-27 13:42:00 +0300
committerIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2024-07-27 12:52:15 +0200
commit54a753654845ecd253d7af7693bbcfbc9d952716 (patch)
treefbef314e43572b618e1e974f077f46328f204b5b
parent95ad46565d8b72a66bff7201b14040f031e8c615 (diff)
Fix issues found by Ruff linter
Change-Id: I0517a69b52e9f5b3da2648e82e63bc35a48e3e99 Reviewed-on: https://gerrit.libreoffice.org/c/dictionaries/+/171091 Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
-rw-r--r--en/Lightproof.py9
-rw-r--r--en/pythonpath/lightproof_handler_en.py6
-rw-r--r--en/pythonpath/lightproof_impl_en.py17
-rw-r--r--hu_HU/Lightproof.py9
-rw-r--r--hu_HU/pythonpath/lightproof_handler_hu_HU.py6
-rw-r--r--hu_HU/pythonpath/lightproof_impl_hu_HU.py17
-rw-r--r--pt_BR/Lightproof.py17
-rw-r--r--pt_BR/pythonpath/lightproof_handler_pt_BR.py10
-rw-r--r--pt_BR/pythonpath/lightproof_impl_pt_BR.py32
-rw-r--r--ru_RU/Lightproof.py9
-rw-r--r--ru_RU/pythonpath/lightproof_handler_ru_RU.py6
-rw-r--r--ru_RU/pythonpath/lightproof_impl_ru_RU.py17
12 files changed, 86 insertions, 69 deletions
diff --git a/en/Lightproof.py b/en/Lightproof.py
index 3003810..62e5fa7 100644
--- a/en/Lightproof.py
+++ b/en/Lightproof.py
@@ -2,7 +2,10 @@
# Lightproof grammar checker for LibreOffice and OpenOffice.org
# 2009-2012 (c) László Németh (nemeth at numbertext org), license: MPL 1.1 / GPLv3+ / LGPLv3+
-import uno, unohelper, os, sys, traceback
+import uno
+import unohelper
+import os
+import traceback
from lightproof_impl_en import locales
from lightproof_impl_en import pkg
import lightproof_impl_en
@@ -15,7 +18,7 @@ from com.sun.star.lang import Locale
# reload in obj.reload in Python 3
try:
from obj import reload
-except:
+except Exception:
pass
class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
@@ -117,7 +120,7 @@ class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XSer
return aRes
aRes.aText = ""
return aRes
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print(traceback.format_exc())
diff --git a/en/pythonpath/lightproof_handler_en.py b/en/pythonpath/lightproof_handler_en.py
index 8d2150f..ef2bf34 100644
--- a/en/pythonpath/lightproof_handler_en.py
+++ b/en/pythonpath/lightproof_handler_en.py
@@ -14,16 +14,16 @@ def load(context):
l = LightproofOptionsEventHandler(context)
for i in lightproof_opts_en.lopts:
l.load(i)
- except:
+ except Exception:
pass
def get_option(page, option):
try:
return options[page + "," + option]
- except:
+ except Exception:
try:
return options[page[:2] + "," + option]
- except:
+ except Exception:
return 0
def set_option(page, option, value):
diff --git a/en/pythonpath/lightproof_impl_en.py b/en/pythonpath/lightproof_impl_en.py
index e9c7588..bd8b1c1 100644
--- a/en/pythonpath/lightproof_impl_en.py
+++ b/en/pythonpath/lightproof_impl_en.py
@@ -1,5 +1,10 @@
# -*- encoding: UTF-8 -*-
-import uno, re, sys, os, traceback
+import uno
+import re
+import sys
+import os
+import traceback
+import lightproof_handler_en
from com.sun.star.text.TextMarkupType import PROOFREADING
from com.sun.star.beans import PropertyValue
@@ -10,8 +15,6 @@ version = "0.4.3"
author = "László Németh"
name = "Lightproof grammar checker (English)"
-import lightproof_handler_en
-
# loaded rules (check for Update mechanism of the editor)
try:
langrule
@@ -86,7 +89,7 @@ def stem(rLoc, word):
global stems
if not word:
return []
- if not word in stems:
+ if word not in stems:
x = spellchecker.spell(u"<?xml?><query type='stem'><word>" + word + "</word></query>", rLoc, ())
if not x:
return []
@@ -150,7 +153,7 @@ def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndP
s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
for i in get_rule(LOCALE).dic:
# 0: regex, 1: replacement, 2: message, 3: condition, 4: ngroup, (5: oldline), 6: case sensitive ?
- if i[0] and not str(i[0]) in ignore:
+ if i[0] and str(i[0]) not in ignore:
for m in i[0].finditer(s):
try:
if not i[3] or eval(i[3]):
@@ -213,7 +216,7 @@ def compile_rules(dic):
else:
i += [False]
i[0] = re.compile(i[0])
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print("Lightproof: bad regular expression: ", traceback.format_exc())
i[0] = None
@@ -221,7 +224,7 @@ def compile_rules(dic):
def get_rule(loc):
try:
return langrule[pkg]
- except:
+ except Exception:
langrule[pkg] = __import__("lightproof_" + pkg)
compile_rules(langrule[pkg].dic)
return langrule[pkg]
diff --git a/hu_HU/Lightproof.py b/hu_HU/Lightproof.py
index daeddeb..37338d7 100644
--- a/hu_HU/Lightproof.py
+++ b/hu_HU/Lightproof.py
@@ -2,7 +2,10 @@
# Lightproof grammar checker for LibreOffice and OpenOffice.org
# 2009-2012 (c) László Németh (nemeth at numbertext org), license: MPL 1.1 / GPLv3+ / LGPLv3+
-import uno, unohelper, os, sys, traceback
+import uno
+import unohelper
+import os
+import traceback
from lightproof_impl_hu_HU import locales
from lightproof_impl_hu_HU import pkg
import lightproof_impl_hu_HU
@@ -15,7 +18,7 @@ from com.sun.star.lang import Locale
# reload in obj.reload in Python 3
try:
from obj import reload
-except:
+except Exception:
pass
class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
@@ -118,7 +121,7 @@ class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XSer
return aRes
aRes.aText = ""
return aRes
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print(traceback.format_exc())
diff --git a/hu_HU/pythonpath/lightproof_handler_hu_HU.py b/hu_HU/pythonpath/lightproof_handler_hu_HU.py
index 9a9e28e..f6b8944 100644
--- a/hu_HU/pythonpath/lightproof_handler_hu_HU.py
+++ b/hu_HU/pythonpath/lightproof_handler_hu_HU.py
@@ -14,16 +14,16 @@ def load(context):
l = LightproofOptionsEventHandler(context)
for i in lightproof_opts_hu_HU.lopts:
l.load(i)
- except:
+ except Exception:
pass
def get_option(page, option):
try:
return options[page + "," + option]
- except:
+ except Exception:
try:
return options[page[:2] + "," + option]
- except:
+ except Exception:
return 0
def set_option(page, option, value):
diff --git a/hu_HU/pythonpath/lightproof_impl_hu_HU.py b/hu_HU/pythonpath/lightproof_impl_hu_HU.py
index 361e7a1..27dfabc 100644
--- a/hu_HU/pythonpath/lightproof_impl_hu_HU.py
+++ b/hu_HU/pythonpath/lightproof_impl_hu_HU.py
@@ -1,6 +1,11 @@
# -*- encoding: UTF-8 -*-
from __future__ import unicode_literals
-import uno, re, sys, os, traceback
+import uno
+import re
+import sys
+import os
+import traceback
+import lightproof_handler_hu_HU
from com.sun.star.text.TextMarkupType import PROOFREADING
from com.sun.star.beans import PropertyValue
@@ -11,8 +16,6 @@ version = "1.6.4"
author = "László Németh"
name = "Lightproof grammar checker (magyar)"
-import lightproof_handler_hu_HU
-
# loaded rules (check for Update mechanism of the editor)
try:
langrule
@@ -89,7 +92,7 @@ def stem(rLoc, word):
global stems
if not word:
return []
- if not word in stems:
+ if word not in stems:
x = spellchecker.spell(u"<?xml?><query type='stem'><word>" + word + "</word></query>", rLoc, ())
if not x:
return []
@@ -153,7 +156,7 @@ def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndP
s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
for i in get_rule(LOCALE).dic:
# 0: regex, 1: replacement, 2: message, 3: condition, 4: ngroup, (5: oldline), 6: case sensitive ?
- if i[0] and not str(i[0]) in ignore:
+ if i[0] and str(i[0]) not in ignore:
for m in i[0].finditer(s):
try:
if not i[3] or eval(i[3]):
@@ -218,7 +221,7 @@ def compile_rules(dic):
else:
i += [False]
i[0] = re.compile(i[0])
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print("Lightproof: bad regular expression: " + str(traceback.format_exc()))
i[0] = None
@@ -226,7 +229,7 @@ def compile_rules(dic):
def get_rule(loc):
try:
return langrule[pkg]
- except:
+ except Exception:
langrule[pkg] = __import__("lightproof_" + pkg)
compile_rules(langrule[pkg].dic)
return langrule[pkg]
diff --git a/pt_BR/Lightproof.py b/pt_BR/Lightproof.py
index 61099ff..adb939c 100644
--- a/pt_BR/Lightproof.py
+++ b/pt_BR/Lightproof.py
@@ -2,11 +2,11 @@
# Lightproof grammar checker for LibreOffice and OpenOffice.org
# 2009-2012 (c) Laszlo Nemeth (nemeth at numbertext org), license: MPL 1.1 / GPLv3+ / LGPLv3+
-import uno, unohelper, os, sys, traceback
-locales = {'pt-BR': ['pt', 'BR', '']}
-pkg = "pt_BR"
+import uno
+import unohelper
+import os
+import traceback
import lightproof_handler_pt_BR
-
from com.sun.star.linguistic2 import XProofreader, XSupportedLocales
from com.sun.star.linguistic2 import ProofreadingResult, SingleProofreadingError
from com.sun.star.lang import XServiceInfo, XServiceName, XServiceDisplayName
@@ -14,9 +14,12 @@ from com.sun.star.lang import Locale
# reload in obj.reload in Python 3
try:
from obj import reload
-except:
+except Exception:
pass
+locales = {'pt-BR': ['pt', 'BR', '']}
+pkg = "pt_BR"
+
class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
def __init__( self, ctx, *args ):
@@ -64,7 +67,7 @@ class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XSer
nSuggestedSentenceEndPos, rProperties):
import lightproof_impl_pt_BR
currentContext = uno.getComponentContext()
- if lightproof_impl_pt_BR.SMGR == None:
+ if lightproof_impl_pt_BR.SMGR is None:
lightproof_impl_pt_BR.SMGR = currentContext.ServiceManager
lightproof_impl_pt_BR.spellchecker = \
lightproof_impl_pt_BR.SMGR.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker", currentContext)
@@ -119,7 +122,7 @@ class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XSer
return aRes
aRes.aText = ""
return aRes
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print(traceback.format_exc())
diff --git a/pt_BR/pythonpath/lightproof_handler_pt_BR.py b/pt_BR/pythonpath/lightproof_handler_pt_BR.py
index 9338da6..35c06cb 100644
--- a/pt_BR/pythonpath/lightproof_handler_pt_BR.py
+++ b/pt_BR/pythonpath/lightproof_handler_pt_BR.py
@@ -1,11 +1,11 @@
import uno
import unohelper
import lightproof_opts_pt_BR
-pkg = "pt_BR"
-
from com.sun.star.lang import XServiceInfo
from com.sun.star.awt import XContainerWindowEventHandler
+pkg = "pt_BR"
+
# options
options = {}
@@ -14,16 +14,16 @@ def load(context):
l = LightproofOptionsEventHandler(context)
for i in lightproof_opts_pt_BR.lopts:
l.load(i)
- except:
+ except Exception:
pass
def get_option(page, option):
try:
return options[page + "," + option]
- except:
+ except Exception:
try:
return options[page[:2] + "," + option]
- except:
+ except Exception:
return 0
def set_option(page, option, value):
diff --git a/pt_BR/pythonpath/lightproof_impl_pt_BR.py b/pt_BR/pythonpath/lightproof_impl_pt_BR.py
index faf0fea..bcf8bbc 100644
--- a/pt_BR/pythonpath/lightproof_impl_pt_BR.py
+++ b/pt_BR/pythonpath/lightproof_impl_pt_BR.py
@@ -1,6 +1,11 @@
# -*- encoding: UTF-8 -*-
-import uno, re, sys, os, traceback
+import uno
+import re
+import sys
+import os
+import traceback
+import lightproof_handler_pt_BR
from com.sun.star.text.TextMarkupType import PROOFREADING
from com.sun.star.beans import PropertyValue
@@ -11,8 +16,6 @@ version = "0.4.3"
author = "Raimundo Santos Moura"
name = "Lightproof grammar checker (Portuguese Brazilian)"
-import lightproof_handler_pt_BR
-
# loaded rules (check for Update mechanism of the editor)
try:
langrule
@@ -38,7 +41,7 @@ def option(lang, opt):
# filtering affix fields (ds, is, ts etc.)
def onlymorph(st):
- if st != None:
+ if st is not None:
st = re.sub(r"^.*(st:|po:)", r"\\1", st) # keep last word part
st = re.sub(r"\\b(?=[dit][sp]:)","@", st) # and its affixes
st = re.sub(r"(?<!@)\\b\w\w:\w+","", st).replace('@','').strip()
@@ -89,7 +92,7 @@ def stem(rLoc, word):
global stems
if not word:
return []
- if not word in stems:
+ if word not in stems:
x = spellchecker.spell(u"<?xml?><query type='stem'><word>" + word + "</word></query>", rLoc, ())
if not x:
return []
@@ -141,9 +144,9 @@ def wordmin(s, n):
def calc(funcname, par):
global calcfunc
global SMGR
- if calcfunc == None:
+ if calcfunc is None:
calcfunc = SMGR.createInstance( "com.sun.star.sheet.FunctionAccess")
- if calcfunc == None:
+ if calcfunc is None:
return None
return calcfunc.callFunction(funcname, par)
@@ -153,7 +156,7 @@ def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndP
s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
for i in get_rule(LOCALE).dic:
# 0: regex, 1: replacement, 2: message, 3: condition, 4: ngroup, (5: oldline), 6: case sensitive ?
- if i[0] and not str(i[0]) in ignore:
+ if i[0] and str(i[0]) not in ignore:
for m in i[0].finditer(s):
try:
if not i[3] or eval(i[3]):
@@ -216,7 +219,7 @@ def compile_rules(dic):
else:
i += [False]
i[0] = re.compile(i[0])
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print("Lightproof: bad regular expression: ", traceback.format_exc())
i[0] = None
@@ -224,7 +227,7 @@ def compile_rules(dic):
def get_rule(loc):
try:
return langrule[pkg]
- except:
+ except Exception:
langrule[pkg] = __import__("lightproof_" + pkg)
compile_rules(langrule[pkg].dic)
return langrule[pkg]
@@ -1382,7 +1385,6 @@ aacento = {"abada": "abadá",
"retrograda": "retrógrada",
"retrogradas": "retrógradas",
"retrogrado": "retrógrado",
-"retrogrado": "retrógrado",
"reusa": "reúsa",
"reusas": "reúsas",
"reuso": "reúso",
@@ -2563,7 +2565,7 @@ varGenera = {"a": "a", "A": "A","À":"À","à":"à",
"Neste": "Nesta", "no": "na", "No": "Na", "nossa": "nossa",
"Nossa": "Nossa", "nosso": "nossa", "Nosso": "Nossa",
"o": "a", "O": "A", "outra": "outra", "Outra": "Outra",
-"outro": "outra", "Outra": "Outra", "pela": "pela",
+"outro": "outra", "pela": "pela",
"Pela": "Pela", "pelo": "pela", "Pelo": "Pela",
"pequena": "pequena", "Pequena": "Pequena", "pequeno": "pequena", "Pequeno": "Pequena",
"pouca": "pouca", "Pouca": "Pouca", "pouco": "pouca", "Pouco": "Pouca",
@@ -12741,7 +12743,6 @@ mProclise = {"abaixo": "Abaixo",
"pouca": "Pouca",
"poucas": "Poucas",
"pouco": "Pouco",
-"pouco": "Pouco",
"poucos": "Poucos",
"quando": "Quando",
"quanto": "Quanto",
@@ -20606,7 +20607,6 @@ ccvbFsvo = {"antepor": "antepuser",
"expor": "expuser",
"fazer": "fizer",
"impor": "impuser",
-"impor": "impuser",
"indispor": "indispuser",
"interpor": "interpuser",
"justapor": "justapuser",
@@ -20627,7 +20627,6 @@ ccvbFsvo = {"antepor": "antepuser",
"reexpor": "reexpuser",
"refazer": "refizer",
"reimpor": "reimpuser",
-"reimpor": "reimpuser",
"repor": "repuser",
"repropor": "repropuser",
"reter": "retiver",
@@ -20662,7 +20661,6 @@ aaVblgtps = {"continua": "continua",
"continuamos": "continua",
"continuar": "continuar",
"continuara": "continuara",
-"continuara": "continuara",
"continuará": "continuará",
"continuaram": "continuou",
"continuáramos": "continuara",
@@ -20741,7 +20739,6 @@ aaVblgtps = {"continua": "continua",
"estivemos": "esteve",
"estiver": "estiver",
"estivera": "estivera",
-"estivera": "estivera",
"estiveram": "esteve",
"estivéramos": "estivera",
"estiveras": "estivera",
@@ -20902,7 +20899,6 @@ aaVblgtps = {"continua": "continua",
"permanecermos": "permanecer",
"permaneces": "permanece",
"permanecesse": "permanecesse",
-"permanecesse": "permanecesse",
"permanecêsseis": "permanecesse",
"permanecessem": "permanecesse",
"permanecêssemos": "permanecesse",
diff --git a/ru_RU/Lightproof.py b/ru_RU/Lightproof.py
index 198b762..bc02a8e 100644
--- a/ru_RU/Lightproof.py
+++ b/ru_RU/Lightproof.py
@@ -2,7 +2,10 @@
# Lightproof grammar checker for LibreOffice and OpenOffice.org
# 2009-2012 (c) László Németh (nemeth at numbertext org), license: MPL 1.1 / GPLv3+ / LGPLv3+
-import uno, unohelper, os, sys, traceback
+import uno
+import unohelper
+import os
+import traceback
from lightproof_impl_ru_RU import locales
from lightproof_impl_ru_RU import pkg
import lightproof_impl_ru_RU
@@ -15,7 +18,7 @@ from com.sun.star.lang import Locale
# reload in obj.reload in Python 3
try:
from obj import reload
-except:
+except Exception:
pass
class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales):
@@ -118,7 +121,7 @@ class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XSer
return aRes
aRes.aText = ""
return aRes
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print(traceback.format_exc())
diff --git a/ru_RU/pythonpath/lightproof_handler_ru_RU.py b/ru_RU/pythonpath/lightproof_handler_ru_RU.py
index e6dbc72..2410687 100644
--- a/ru_RU/pythonpath/lightproof_handler_ru_RU.py
+++ b/ru_RU/pythonpath/lightproof_handler_ru_RU.py
@@ -14,16 +14,16 @@ def load(context):
l = LightproofOptionsEventHandler(context)
for i in lightproof_opts_ru_RU.lopts:
l.load(i)
- except:
+ except Exception:
pass
def get_option(page, option):
try:
return options[page + "," + option]
- except:
+ except Exception:
try:
return options[page[:2] + "," + option]
- except:
+ except Exception:
return 0
def set_option(page, option, value):
diff --git a/ru_RU/pythonpath/lightproof_impl_ru_RU.py b/ru_RU/pythonpath/lightproof_impl_ru_RU.py
index 808617c..5a67e72 100644
--- a/ru_RU/pythonpath/lightproof_impl_ru_RU.py
+++ b/ru_RU/pythonpath/lightproof_impl_ru_RU.py
@@ -1,5 +1,10 @@
# -*- encoding: UTF-8 -*-
-import uno, re, sys, os, traceback
+import uno
+import re
+import sys
+import os
+import traceback
+import lightproof_handler_ru_RU
from com.sun.star.text.TextMarkupType import PROOFREADING
from com.sun.star.beans import PropertyValue
@@ -10,8 +15,6 @@ version = "0.3.4"
author = "Yakov Reztsov <yr at myooo dot ru>"
name = "Lightproof grammar checker (Russian)"
-import lightproof_handler_ru_RU
-
# loaded rules (check for Update mechanism of the editor)
try:
langrule
@@ -88,7 +91,7 @@ def stem(rLoc, word):
global stems
if not word:
return []
- if not word in stems:
+ if word not in stems:
x = spellchecker.spell(u"<?xml?><query type='stem'><word>" + word + "</word></query>", rLoc, ())
if not x:
return []
@@ -152,7 +155,7 @@ def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndP
s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
for i in get_rule(LOCALE).dic:
# 0: regex, 1: replacement, 2: message, 3: condition, 4: ngroup, (5: oldline), 6: case sensitive ?
- if i[0] and not str(i[0]) in ignore:
+ if i[0] and str(i[0]) not in ignore:
for m in i[0].finditer(s):
try:
if not i[3] or eval(i[3]):
@@ -215,7 +218,7 @@ def compile_rules(dic):
else:
i += [False]
i[0] = re.compile(i[0])
- except:
+ except Exception:
if 'PYUNO_LOGLEVEL' in os.environ:
print("Lightproof: bad regular expression: " + str(traceback.format_exc()))
i[0] = None
@@ -223,7 +226,7 @@ def compile_rules(dic):
def get_rule(loc):
try:
return langrule[pkg]
- except:
+ except Exception:
langrule[pkg] = __import__("lightproof_" + pkg)
compile_rules(langrule[pkg].dic)
return langrule[pkg]