sfx2, solenv, sw: fix issues found by Ruff linter
Change-Id: Iab375e8c8aa4c4915f3c70a9ef6aede268e4619f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171138 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
parent
85511e27d2
commit
dffa7b7d0b
19 changed files with 52 additions and 49 deletions
|
@ -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 )
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 + ")")
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
try:
|
||||
from collections.abc import Mapping
|
||||
except:
|
||||
except Exception:
|
||||
from collections import Mapping
|
||||
import gdb
|
||||
import re
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
try:
|
||||
from collections.abc import Mapping
|
||||
except:
|
||||
except Exception:
|
||||
from collections import Mapping
|
||||
import gdb
|
||||
import re
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue