odk, oox, pyuno: fix issues found by Ruff linter
Change-Id: I79d56453877a10502768b522ca93da3990891c0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171098 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
@@ -71,11 +71,6 @@ class ChartInCalc(object):
|
||||
def test_data_point_properties(self):
|
||||
# set properties for a single data point
|
||||
try:
|
||||
# determine the maximum value of the first series
|
||||
data_array = self._chart_document.getData()
|
||||
data = data_array.getData()
|
||||
max_value = max([data[i][1] for i in range(len(data))])
|
||||
|
||||
# first parameter is the index of the point, the second one is the series
|
||||
point_prop = self._diagram.getDataPointProperties(0, 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]
|
||||
id_out_name = sys.argv[2]
|
||||
@@ -69,7 +70,7 @@ shift = 16
|
||||
|
||||
idfile.write("const size_t NMSP_SHIFT = {};\n".format(shift))
|
||||
|
||||
i = 1;
|
||||
i = 1
|
||||
for token in sorted(namespaces.keys()):
|
||||
idfile.write("const sal_Int32 NMSP_{} = {} << NMSP_SHIFT;\n".format(token, i))
|
||||
cur_id = i << shift
|
||||
|
@@ -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]
|
||||
id_out_name = sys.argv[2]
|
||||
@@ -37,7 +38,7 @@ with open(infile_name) as infile:
|
||||
idfile = open(id_out_name, 'w')
|
||||
namefile = open(name_out_name, 'w')
|
||||
|
||||
i = 0;
|
||||
i = 0
|
||||
for token in sorted(props.keys()):
|
||||
idfile.write("const sal_Int32 {} = {};\n".format(props[token], i))
|
||||
namefile.write("/* {} */ \"{}\",\n".format(i, token))
|
||||
|
@@ -37,7 +37,7 @@ def main():
|
||||
rowset.CommandType = COMMAND
|
||||
rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio"
|
||||
|
||||
rowset.execute();
|
||||
rowset.execute()
|
||||
|
||||
print("Identifier\tAuthor")
|
||||
|
||||
@@ -46,7 +46,7 @@ def main():
|
||||
while rowset.next():
|
||||
print(rowset.getString(id) + "\t" + repr(rowset.getString(author)))
|
||||
|
||||
rowset.dispose();
|
||||
rowset.dispose()
|
||||
|
||||
main()
|
||||
|
||||
|
@@ -17,7 +17,8 @@
|
||||
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
#
|
||||
|
||||
import getopt,sys
|
||||
import getopt
|
||||
import sys
|
||||
import uno
|
||||
|
||||
from unohelper import Base,systemPathToFileUrl
|
||||
|
@@ -75,7 +75,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertEqual(0, count)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# num = len(obj) # Number of elements
|
||||
@@ -94,7 +94,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertEqual(1, count)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# val = obj[0] # Access by index
|
||||
@@ -119,7 +119,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
self.readValuesTestFixture(doc, 2, 1, 1)
|
||||
self.readValuesTestFixture(doc, 2, 2, IndexError)
|
||||
self.readValuesTestFixture(doc, 2, 3, IndexError)
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
def test_XIndexAccess_ReadIndex_Single_Invalid(self):
|
||||
doc = self.createBlankTextDocument()
|
||||
@@ -129,7 +129,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
self.readValuesTestFixture(doc, 0, (0, 1), TypeError)
|
||||
self.readValuesTestFixture(doc, 0, [0, 1], TypeError)
|
||||
self.readValuesTestFixture(doc, 0, {'a': 'b'}, TypeError)
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# val1,val2 = obj[2:4] # Access by slice
|
||||
@@ -143,7 +143,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
key = slice(j, k)
|
||||
expected = t[key]
|
||||
self.readValuesTestFixture(doc, i, key, expected)
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# val1,val2 = obj[0:3:2] # Access by extended slice
|
||||
@@ -158,7 +158,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
key = slice(j, k, l)
|
||||
expected = t[key]
|
||||
self.readValuesTestFixture(doc, i, key, expected)
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# if val in obj: ... # Test value presence
|
||||
@@ -179,7 +179,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertTrue(present)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# if val in obj: ... # Test value presence
|
||||
@@ -195,7 +195,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertFalse(present)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# if val in obj: ... # Test value presence
|
||||
@@ -211,7 +211,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertFalse(present)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# if val in obj: ... # Test value presence
|
||||
@@ -225,7 +225,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
with self.assertRaises(TypeError):
|
||||
_ = {} in doc.Footnotes
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# for val in obj: ... # Implicit iterator (values)
|
||||
@@ -243,7 +243,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
# Then
|
||||
self.assertEqual(0, len(read_footnotes))
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# for val in obj: ... # Implicit iterator (values)
|
||||
@@ -266,7 +266,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
self.assertEqual(1, len(read_footnotes))
|
||||
self.assertEqual('foo', read_footnotes[0].Label)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# for val in obj: ... # Implicit iterator (values)
|
||||
@@ -293,7 +293,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
self.assertEqual('foo', read_footnotes[0].Label)
|
||||
self.assertEqual('bar', read_footnotes[1].Label)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
# Tests syntax:
|
||||
# itr = iter(obj) # Named iterator (values)
|
||||
@@ -315,7 +315,7 @@ class TestXIndexAccess(CollectionsTestBase):
|
||||
with self.assertRaises(StopIteration):
|
||||
next(itr)
|
||||
|
||||
doc.close(True);
|
||||
doc.close(True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@@ -40,16 +40,16 @@ def splitUrl( url ):
|
||||
|
||||
g_loadedComponents = {}
|
||||
def checkForPythonPathBesideComponent( url ):
|
||||
path = unohelper.fileUrlToSystemPath( url+"/pythonpath.zip" );
|
||||
path = unohelper.fileUrlToSystemPath( url+"/pythonpath.zip" )
|
||||
if DEBUG == 1:
|
||||
print(b"checking for existence of " + encfile( path ))
|
||||
if 1 == os.access( encfile( path ), os.F_OK) and not path in sys.path:
|
||||
if 1 == os.access( encfile( path ), os.F_OK) and path not in sys.path:
|
||||
if DEBUG == 1:
|
||||
print(b"adding " + encfile( path ) + b" to sys.path")
|
||||
sys.path.append( path )
|
||||
|
||||
path = unohelper.fileUrlToSystemPath( url+"/pythonpath" );
|
||||
if 1 == os.access( encfile( path ), os.F_OK) and not path in sys.path:
|
||||
path = unohelper.fileUrlToSystemPath( url+"/pythonpath" )
|
||||
if 1 == os.access( encfile( path ), os.F_OK) and path not in sys.path:
|
||||
if DEBUG == 1:
|
||||
print(b"adding " + encfile( path ) + b" to sys.path")
|
||||
sys.path.append( path )
|
||||
@@ -107,7 +107,7 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
|
||||
if -1 != nSlash:
|
||||
path = unohelper.fileUrlToSystemPath( dependent[0:nSlash] )
|
||||
dependent = dependent[nSlash+1:len(dependent)]
|
||||
if not path in sys.path:
|
||||
if path not in sys.path:
|
||||
sys.path.append( path )
|
||||
mod = __import__( dependent )
|
||||
path_component, dot, rest = dependent.partition('.')
|
||||
@@ -117,13 +117,13 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
|
||||
return mod
|
||||
else:
|
||||
if DEBUG:
|
||||
print("Unknown protocol '" + protocol + "'");
|
||||
print("Unknown protocol '" + protocol + "'")
|
||||
raise RuntimeException( "PythonLoader: Unknown protocol " +
|
||||
protocol + " in url " +url, self )
|
||||
except Exception as e:
|
||||
if DEBUG:
|
||||
print ("Python import exception " + str(type(e)) +
|
||||
" message " + str(e) + " args " + str(e.args));
|
||||
" message " + str(e) + " args " + str(e.args))
|
||||
raise RuntimeException( "Couldn't load " + url + " for reason " + str(e), None )
|
||||
return None
|
||||
|
||||
|
@@ -49,9 +49,16 @@ warning:: Tested platforms are Linux, Mac OS X & Windows
|
||||
:References:
|
||||
.. _ActiveState retry Python decorator: http://code.activestate.com/recipes/580745-retry-decorator-in-python/
|
||||
"""
|
||||
import os, random, signal, subprocess # in bootstrap()
|
||||
from sys import platform # in bootstrap()
|
||||
import itertools, time # in retry() decorator
|
||||
# in bootstrap()
|
||||
import os
|
||||
import random
|
||||
import signal
|
||||
import subprocess
|
||||
from sys import platform
|
||||
# in retry() decorator
|
||||
import itertools
|
||||
import time
|
||||
|
||||
import uno
|
||||
from com.sun.star.connection import NoConnectException
|
||||
from com.sun.star.uno import Exception as UnoException
|
||||
|
Reference in New Issue
Block a user