diff --git a/sfx2/qa/python/check_sidebar.py b/sfx2/qa/python/check_sidebar.py index 7f188baa4ba7..3ea8542d2e03 100644 --- a/sfx2/qa/python/check_sidebar.py +++ b/sfx2/qa/python/check_sidebar.py @@ -44,7 +44,7 @@ class CheckSidebar(unittest.TestCase): xDecks = xSidebar.getDecks() - first_deck_name = "PropertyDeck"; + first_deck_name = "PropertyDeck" deck_element_names = xDecks.getElementNames() assert ( first_deck_name in deck_element_names ) diff --git a/solenv/bin/finish-gbuild-trace.py b/solenv/bin/finish-gbuild-trace.py index fcd31fc23fa9..5acd0b01de8b 100755 --- a/solenv/bin/finish-gbuild-trace.py +++ b/solenv/bin/finish-gbuild-trace.py @@ -84,7 +84,7 @@ with open(filename + ".tmp", "w") as outfile: slot_start_time[tid-1] = int(match.group(3)) elif match.group(2) == 'E': tid = free_slot(match.group(1), match.group(4)) # "name", "args" - if not match.group(1) in totals_time: + if match.group(1) not in totals_time: totals_time[match.group(1)] = 0 totals_count[match.group(1)] = 0 totals_time[match.group(1)] += int(match.group(3)) - slot_start_time[tid-1] diff --git a/solenv/bin/generate-tokens.py b/solenv/bin/generate-tokens.py index 2dc3c3fd4cfc..40b6b12aae9b 100644 --- a/solenv/bin/generate-tokens.py +++ b/solenv/bin/generate-tokens.py @@ -15,7 +15,8 @@ # the License at http://www.apache.org/licenses/LICENSE-2.0 . # -import sys, re +import sys +import re infile_name = sys.argv[1] idfile_out_name = sys.argv[2] @@ -37,7 +38,7 @@ struct xmltoken { %% """) -token_count = 0; +token_count = 0 tokens = {} with open(infile_name) as infile: @@ -45,16 +46,16 @@ with open(infile_name) as infile: line = line.strip() # check for valid characters if not re.match(r'[a-zA-Z0-9-_]+$', line): - sys.exit("Error: invalid character in token '{}'".format(line)); - cur_id = "XML_" + line; + sys.exit("Error: invalid character in token '{}'".format(line)) + cur_id = "XML_" + line # we have two ids with similar names("cut-offs" and "cut_offs") if cur_id == "XML_cut_offs": - cur_id = "cut_offs2"; + cur_id = "cut_offs2" cur_id = cur_id.replace('-', '_') tokens[line] = cur_id idfile.write("const sal_Int32 {} = {};\n".format(cur_id, token_count)) - namefile.write("\"{}\",\n".format(line)); - gperffile.write("{},{}\n".format(line, cur_id)); + namefile.write("\"{}\",\n".format(line)) + gperffile.write("{},{}\n".format(line, cur_id)) token_count += 1 idfile.write("const sal_Int32 XML_TOKEN_COUNT = {};\n".format(token_count)) diff --git a/solenv/bin/image-sort.py b/solenv/bin/image-sort.py index 5d248684b4a6..43a26dc5468d 100644 --- a/solenv/bin/image-sort.py +++ b/solenv/bin/image-sort.py @@ -17,7 +17,9 @@ # the License at http://www.apache.org/licenses/LICENSE-2.0 . # -import sys, os, re +import sys +import os +import re import argparse global_list = [] diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py index 5ccc194e6307..51e0bb8d6782 100644 --- a/solenv/bin/pack_images.py +++ b/solenv/bin/pack_images.py @@ -88,7 +88,7 @@ def main(args): try: LOGGER.info("Remove temporary directory %s", tmp_dir) shutil.rmtree(tmp_dir) - except Exception as e: + except Exception: LOGGER.error("Unable to remove temporary directory %s", tmp_dir) sys.exit(2) else: @@ -507,7 +507,7 @@ def parse_image_list(imagelist_filenames): try: fh = open(imagelist_filename) - except IOError as e: + except IOError: LOGGER.error("Cannot open imagelist file %s", imagelist_filename) sys.exit(2) else: diff --git a/solenv/bin/polib.py b/solenv/bin/polib.py index e1511cdb975f..3a6afec5a238 100644 --- a/solenv/bin/polib.py +++ b/solenv/bin/polib.py @@ -871,7 +871,7 @@ class _BaseEntry(object): try: usedirect = False ret = u('\n').join(x.decode('utf-8') for x in ret) - except: + except Exception: usedirect = True if usedirect: ret = u('\n').join(ret) diff --git a/solenv/gbuild/gen-autoinstall.py b/solenv/gbuild/gen-autoinstall.py index d55ab51d3822..d42e8ae96ace 100644 --- a/solenv/gbuild/gen-autoinstall.py +++ b/solenv/gbuild/gen-autoinstall.py @@ -73,25 +73,25 @@ for (gid, link, target) in autosdklibs: scp2libtemplates = set([ "URE_PRIVATE_LIB", "LIBO_LIB_FILE", "LIBO_LIB_FILE_BINARYTABLE", "LIBO_LIB_FILE_COMPONENTCONDITION", "SHLXTHDL_LIB_FILE", "SHLXTHDL_X64_LIB_FILE_COMPONENTCONDITION" ]) for (gid, libfile) in autolibs: - if not(scp2libtemplate in scp2libtemplates): + if scp2libtemplate not in scp2libtemplates: raise Exception("invalid scp2libtemplate \"" + scp2libtemplate + "\"") print(scp2libtemplate + "(" + gid + "," + libfile + scp2componentcondition + ")") scp2exetemplates = set([ "URE_EXECUTABLE", "LIBO_EXECUTABLE", "LIBO_EXECUTABLE_COMPONENTCONDITION", "SDK_EXECUTABLE" ]) for (gid, exefile) in autoexes: - if not(scp2exetemplate in scp2exetemplates): + if scp2exetemplate not in scp2exetemplates: raise Exception("invalid scp2exetemplate \"" + scp2exetemplate + "\"") print(scp2exetemplate + "(" + gid + "," + exefile + scp2componentcondition + ")") scp2jartemplates = set([ "URE_JAR_FILE", "LIBO_JAR_FILE" ]) for (gid, jarfile) in autojars: - if not(scp2jartemplate in scp2jartemplates): + if scp2jartemplate not in scp2jartemplates: raise Exception("invalid scp2jartemplate \"" + scp2jartemplate + "\"") print(scp2jartemplate + "(" + gid + "," + jarfile + scp2componentcondition + ")") scp2pkgtemplates = set([ "PACKAGE_FILELIST", "PACKAGE_FILELIST_COMPONENTCONDITION","PACKAGE_FILELIST_FONT", "SDK_PACKAGE_FILELIST" ]) for (gid, pkgfilelist) in autopkgs: - if not(scp2pkgtemplate in scp2pkgtemplates): + if scp2pkgtemplate not in scp2pkgtemplates: raise Exception("invalid scp2pkgtemplate \"" + scp2pkgtemplate + "\"") print(scp2pkgtemplate + "(" + gid + "," + pkgfilelist + scp2componentcondition + ")") diff --git a/solenv/gdb/boost/ptr_container.py b/solenv/gdb/boost/ptr_container.py index 9b61268302cf..9e2cf9d63922 100644 --- a/solenv/gdb/boost/ptr_container.py +++ b/solenv/gdb/boost/ptr_container.py @@ -79,7 +79,7 @@ class PtrStdPrinterBase(object): try: import libstdcxx.v6.printers std = libstdcxx.v6.printers - except: + except Exception: pass def _get_sequence_printer(self, typename): diff --git a/solenv/gdb/boost/util/printing.py b/solenv/gdb/boost/util/printing.py index 22bf29f8030a..a2310c4851bf 100644 --- a/solenv/gdb/boost/util/printing.py +++ b/solenv/gdb/boost/util/printing.py @@ -21,7 +21,7 @@ try: from collections.abc import Mapping -except: +except Exception: from collections import Mapping import gdb import re diff --git a/solenv/gdb/libreoffice/cppu.py b/solenv/gdb/libreoffice/cppu.py index 5114dbe127d5..c5b257b72b5d 100644 --- a/solenv/gdb/libreoffice/cppu.py +++ b/solenv/gdb/libreoffice/cppu.py @@ -43,7 +43,7 @@ class UnoReferencePrinter(object): if iface: try: return '%s to (%s) %s' % (self.typename, str(iface.dynamic_type), str(iface)) - except: + except Exception: # fallback for potential problem: # base class 'com::sun::star::uno::XInterface' is ambiguous return '%s to (XInterface) %s' % (self.typename, str(iface)) diff --git a/solenv/gdb/libreoffice/sw.py b/solenv/gdb/libreoffice/sw.py index 89ac80e5eb2a..1f8b8c1636e2 100644 --- a/solenv/gdb/libreoffice/sw.py +++ b/solenv/gdb/libreoffice/sw.py @@ -19,8 +19,8 @@ class SwPositionPrinter(object): self.value = value def to_string(self): - node = self.value['nNode']['m_pNode'].dereference(); - block = node['m_pBlock'].dereference(); + node = self.value['nNode']['m_pNode'].dereference() + block = node['m_pBlock'].dereference() nodeindex = block['nStart'] + node['m_nOffset'] offset = self.value['nContent']['m_nIndex'] return "%s (node %d, offset %d)" % (self.typename, nodeindex, offset) @@ -33,8 +33,8 @@ class SwNodeIndexPrinter(object): self.value = value def to_string(self): - node = self.value['m_pNode'].dereference(); - block = node['m_pBlock'].dereference(); + node = self.value['m_pNode'].dereference() + block = node['m_pBlock'].dereference() nodeindex = block['nStart'] + node['m_nOffset'] return "%s (node %d)" % (self.typename, nodeindex) @@ -50,7 +50,7 @@ class SwContentIndexPrinter(object): nodeindex = 'none' if pNode: node = pNode.dereference() - block = node['m_pBlock'].dereference(); + block = node['m_pBlock'].dereference() nodeindex = str(block['nStart'] + node['m_nOffset']) offset = self.value['m_nIndex'] return "%s (node %s offset %s)" % (self.typename, nodeindex, offset) diff --git a/solenv/gdb/libreoffice/util/printing.py b/solenv/gdb/libreoffice/util/printing.py index a31e353cfa4d..f50a427cc091 100644 --- a/solenv/gdb/libreoffice/util/printing.py +++ b/solenv/gdb/libreoffice/util/printing.py @@ -9,7 +9,7 @@ try: from collections.abc import Mapping -except: +except Exception: from collections import Mapping import gdb import re diff --git a/solenv/lldb/libreoffice/LO.py b/solenv/lldb/libreoffice/LO.py index 3c1134ccadc4..22cb8c927184 100644 --- a/solenv/lldb/libreoffice/LO.py +++ b/solenv/lldb/libreoffice/LO.py @@ -18,7 +18,7 @@ def rtl_String_summary(valobj, dict): length = valobj.GetChildMemberWithName('length').GetValueAsUnsigned(0) buffer = valobj.GetChildMemberWithName('buffer') - buffer_ptr = buffer.AddressOf(); + buffer_ptr = buffer.AddressOf() # return '"' + buffer_ptr.GetPointeeData(0, length).GetString(lldb.SBError(), 0) + '"' return sal_ascii_string(buffer_ptr, length) @@ -33,10 +33,14 @@ def sal_ascii_string(buffer_ptr, length): i = 0 while i < length: c = buffer_ptr.GetPointeeData(i, 1).GetUnsignedInt8(e, 0) - if c == ord('"'): s = s + '\\"' - elif c == ord('\\'): s = s + '\\\\' - elif c == ord('\n'): s = s + '\\n' - elif c == ord('\r'): s = s + '\\r' + if c == ord('"'): + s = s + '\\"' + elif c == ord('\\'): + s = s + '\\\\' + elif c == ord('\n'): + s = s + '\\n' + elif c == ord('\r'): + s = s + '\\r' elif c == ord('\t'): s = s + '\\t' elif c < ord(' '): @@ -61,7 +65,7 @@ def rtl_uString_summary(valobj, dict): length = valobj.GetChildMemberWithName('length').GetValueAsUnsigned(0) buffer = valobj.GetChildMemberWithName('buffer') - buffer_ptr = buffer.AddressOf(); + buffer_ptr = buffer.AddressOf() return sal_unicode_string(buffer_ptr, length) diff --git a/sw/qa/python/set_expression.py b/sw/qa/python/set_expression.py index c5dc5e6ae2e9..65f4b3de01d9 100644 --- a/sw/qa/python/set_expression.py +++ b/sw/qa/python/set_expression.py @@ -27,8 +27,7 @@ class TestSetExpression(unittest.TestCase): xDoc = self.__class__._uno.openEmptyWriterDoc() self.__class__._uno.checkProperties( xDoc.createInstance("com.sun.star.text.textfield.SetExpression"), - {"NumberingType": 0, - "Content": "foo", + {"Content": "foo", "CurrentPresentation": "bar", "NumberFormat": 0, "NumberingType": 0, diff --git a/sw/qa/python/text_portion_enumeration_test.py b/sw/qa/python/text_portion_enumeration_test.py index 0a064f544cf5..c9d859d0267b 100644 --- a/sw/qa/python/text_portion_enumeration_test.py +++ b/sw/qa/python/text_portion_enumeration_test.py @@ -45,7 +45,7 @@ class TreeNode(): return "<{}>".format(self.nodetype) def __eq__(self, other): - return type(self) == type(other) + return type(self) is type(other) def __ne__(self, other): return not self == other @@ -192,7 +192,7 @@ class MetaNode(TreeNode): def __eq__(self, other): try: - return (type(other) == type(self) and + return (type(other) is type(self) and MetaNode.eq(other.xmlid, self.xmlid)) except AttributeError: return False @@ -237,7 +237,7 @@ class BookmarkNode(MarkNode): def __eq__(self, other): try: - return (type(other) == type(self) and + return (type(other) is type(self) and super().__eq__(other) and MetaNode.eq(other.xmlid, self.xmlid)) except AttributeError: @@ -275,7 +275,7 @@ class ReferenceMarkNode(MarkNode): self.nodetype = "ReferenceMark" def __eq__(self, other): - return (type(other) == type(self) and super().__eq__(other)) + return (type(other) is type(self) and super().__eq__(other)) def dup(self): return self._dup(ReferenceMarkNode, self.name) @@ -307,7 +307,7 @@ class DocumentIndexMarkNode(MarkNode): self.nodetype = "DocumentIndexMark" def __eq__(self, other): - return (type(other) == type(self) and super().__eq__(other)) + return (type(other) is type(self) and super().__eq__(other)) def dup(self): return self._dup(DocumentIndexMarkNode, self.name) @@ -3474,7 +3474,7 @@ class TextPortionEnumerationTest(unittest.TestCase): xText = xDoc.getText() xTextEnum = xText.createEnumeration() ## skip to right paragraph - xTextEnum.nextElement(); # skip first -- always empty! + xTextEnum.nextElement() # skip first -- always empty! xElement = xTextEnum.nextElement() # second contains test case xEnum = xElement.createEnumeration() outtree = EnumConverter().convert(xEnum) diff --git a/sw/qa/uitest/writer_tests2/formatCharacter.py b/sw/qa/uitest/writer_tests2/formatCharacter.py index 724b8813029e..73ee39da9fcf 100644 --- a/sw/qa/uitest/writer_tests2/formatCharacter.py +++ b/sw/qa/uitest/writer_tests2/formatCharacter.py @@ -12,7 +12,6 @@ from uitest.uihelper.common import get_state_as_dict from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.uihelper.common import select_pos -from uitest.uihelper.common import select_by_text class formatCharacter(UITestCase): diff --git a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py index 0f8e9f1d305e..e6f73b1b052a 100644 --- a/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py +++ b/sw/qa/uitest/writer_tests5/DateFormFieldPropertiesDialog.py @@ -27,7 +27,7 @@ class dateFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/01/99") # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); + itemsList.getChild("11").executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-01") @@ -73,7 +73,7 @@ class dateFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/01/99") # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); + itemsList.getChild("11").executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-01") @@ -95,7 +95,7 @@ class dateFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Wed 01/Dec 99") # select a new format - itemsList.getChild("11").executeAction("SELECT", tuple()); + itemsList.getChild("11").executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12-01") @@ -120,7 +120,7 @@ class dateFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "12/01/99") # select a new format - itemsList.getChild("3").executeAction("SELECT", tuple()); + itemsList.getChild("3").executeAction("SELECT", tuple()) self.assertEqual(get_state_as_dict(itemsList)["SelectEntryText"], "Dec 1, 1999") diff --git a/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py index c68bc8a73ee0..e043df9b5e24 100644 --- a/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py +++ b/sw/qa/uitest/writer_tests5/DropDownFormFieldPropertiesDialog.py @@ -99,7 +99,7 @@ class dropDownFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList.getChild("3"))["Text"], "4000") # select an item from the list and remove it - itemsList.getChild("1").executeAction("SELECT", tuple()); + itemsList.getChild("1").executeAction("SELECT", tuple()) removeButton.executeAction("CLICK", tuple()) # check whether the right item was removed @@ -120,7 +120,7 @@ class dropDownFormFieldDialog(UITestCase): self.assertEqual(get_state_as_dict(itemsList.getChild("2"))["Text"], "4000") # remove all items - itemsList.getChild("1").executeAction("SELECT", tuple()); + itemsList.getChild("1").executeAction("SELECT", tuple()) removeButton.executeAction("CLICK", tuple()) removeButton.executeAction("CLICK", tuple()) removeButton.executeAction("CLICK", tuple()) diff --git a/sw/qa/uitest/writer_tests8/tdf159102.py b/sw/qa/uitest/writer_tests8/tdf159102.py index c4ece7f725fe..5e99efa1a4c4 100644 --- a/sw/qa/uitest/writer_tests8/tdf159102.py +++ b/sw/qa/uitest/writer_tests8/tdf159102.py @@ -81,8 +81,6 @@ class tdf159102(UITestCase): self.xUITest.executeCommand(".uno:GoToEndOfLine") self.xUITest.executeCommand('.uno:StartOfDocumentSel') self.xUITest.executeCommand('.uno:Delete') - paragraphs = writer_doc.Text.createEnumeration() - para1 = paragraphs.nextElement() # disable UITest that fails reliably # # This was "stas.", i.e. too much shrinking # self.assertEqual("sus egestas.", para1.String)