tdf#158803 F821: xrange undefined, should be range in py3; remove some unused variables
changing range(len()) to enumerate as suggested by Arkadiy Illarionov Change-Id: I5000204281a5f6ded9c411525e612bf84b552f80 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165505 Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
parent
70b3e128ae
commit
96ffaadbcd
4 changed files with 23 additions and 29 deletions
|
@ -355,7 +355,7 @@ def runLoadPrintFileTests(opts, dirs, suffix, reference):
|
|||
def mkImages(file, resolution):
|
||||
argv = [ "gs", "-r" + resolution, "-sOutputFile=" + file + ".%04d.jpeg",
|
||||
"-dNOPROMPT", "-dNOPAUSE", "-dBATCH", "-sDEVICE=jpeg", file ]
|
||||
ret = subprocess.check_call(argv)
|
||||
subprocess.check_call(argv)
|
||||
|
||||
def mkAllImages(dirs, suffix, resolution, reference, failed):
|
||||
if reference:
|
||||
|
|
|
@ -61,7 +61,6 @@ class Parser:
|
|||
"""
|
||||
Extracts the source code comments.
|
||||
"""
|
||||
linenum = 0
|
||||
if self.args.verbose:
|
||||
print("processing file '%s'...\n" % filename)
|
||||
sock = open(filename)
|
||||
|
@ -95,7 +94,6 @@ class Parser:
|
|||
elif "/*" in i and "*/" not in i and not in_comment:
|
||||
# start of a real multiline comment
|
||||
in_comment = True
|
||||
linenum = count
|
||||
s = re.sub(r".*/\*+", "", i.strip(self.strip))
|
||||
if len(s):
|
||||
buf.append(s.strip(self.strip))
|
||||
|
@ -156,7 +154,7 @@ class Parser:
|
|||
if len(path) >= START:
|
||||
return 1
|
||||
diff = START - len(path)
|
||||
if diff % 4 is not 0:
|
||||
if (diff % 4) != 0:
|
||||
padding = 1
|
||||
else:
|
||||
padding = 0
|
||||
|
@ -216,7 +214,7 @@ class Parser:
|
|||
done = False
|
||||
while not done:
|
||||
nextElem = os.path.split(lastElem)[0]
|
||||
if nextElem is not '':
|
||||
if nextElem != '':
|
||||
lastElem = nextElem
|
||||
else:
|
||||
done = True
|
||||
|
@ -378,10 +376,10 @@ class Parser:
|
|||
if not baseDir in directory_allowlist:
|
||||
sys.stderr.write("\n - Error: Missing path %s -\n\n" % baseDir)
|
||||
sys.exit(1)
|
||||
elif directory_allowlist[baseDir] is 0:
|
||||
elif directory_allowlist[baseDir] == 0:
|
||||
self.check_file(path.strip())
|
||||
num_checked = num_checked + 1
|
||||
elif directory_allowlist[baseDir] is 1:
|
||||
elif directory_allowlist[baseDir] == 1:
|
||||
sys.stderr.write("Skipping excluded directory %s\n" % baseDir)
|
||||
directory_allowlist[baseDir] = 2
|
||||
elif not globalscan:
|
||||
|
|
|
@ -95,7 +95,7 @@ def getFunction(frame):
|
|||
start = frame.index(" in ") + len(" in ")
|
||||
try:
|
||||
end = frame.index(" at ", start)
|
||||
except ValueError as e:
|
||||
except ValueError:
|
||||
# argh... stack frames may be split across multiple lines if
|
||||
# a parameter has a fancy pretty printer
|
||||
return frame[start:]
|
||||
|
|
|
@ -54,8 +54,7 @@ def run(command):
|
|||
|
||||
def update_pch(filename, lines, marks):
|
||||
with open(filename, 'w') as f:
|
||||
for i in xrange(len(marks)):
|
||||
mark = marks[i]
|
||||
for i, mark in enumerate(marks):
|
||||
if mark <= TEST_ON:
|
||||
f.write(lines[i])
|
||||
else:
|
||||
|
@ -132,8 +131,7 @@ def get_marks(lines):
|
|||
marks = []
|
||||
min = -1
|
||||
max = -1
|
||||
for i in xrange(len(lines)):
|
||||
line = lines[i]
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith('#include'):
|
||||
marks.append(TEST_ON)
|
||||
min = i if min < 0 else min
|
||||
|
@ -205,8 +203,8 @@ def main():
|
|||
# Simplify further, as sometimes we can have
|
||||
# false positives due to the benign nature
|
||||
# of includes that are not absolutely required.
|
||||
for i in xrange(len(marks)):
|
||||
if marks[i] == GOOD:
|
||||
for i, mark in enumerate(marks):
|
||||
if mark == GOOD:
|
||||
marks[i] = TEST_OFF
|
||||
update_pch(filename, lines, marks)
|
||||
if not run(command):
|
||||
|
@ -214,14 +212,14 @@ def main():
|
|||
marks[i] = GOOD
|
||||
else:
|
||||
marks[i] = BAD
|
||||
elif marks[i] == TEST_OFF:
|
||||
elif mark == TEST_OFF:
|
||||
marks[i] = TEST_ON
|
||||
|
||||
update_pch(filename, lines, marks)
|
||||
|
||||
log('')
|
||||
for i in xrange(len(marks)):
|
||||
if marks[i] == (BAD if FIND_CONFLICTS else GOOD):
|
||||
for i, mark in enumerate(marks):
|
||||
if mark == (BAD if FIND_CONFLICTS else GOOD):
|
||||
print("'{}',".format(get_filename(lines[i].strip('\n'))))
|
||||
|
||||
return 0
|
||||
|
@ -258,8 +256,7 @@ class TestBisectConflict(unittest.TestCase):
|
|||
|
||||
def _update_func(self, lines, marks):
|
||||
self.lines = []
|
||||
for i in xrange(len(marks)):
|
||||
mark = marks[i]
|
||||
for i, mark in enumerate(marks):
|
||||
if mark <= TEST_ON:
|
||||
self.lines.append(lines[i])
|
||||
else:
|
||||
|
@ -282,7 +279,7 @@ class TestBisectConflict(unittest.TestCase):
|
|||
|
||||
def test_conflict(self):
|
||||
lines = self.TEST.split('\n')
|
||||
for pos in xrange(len(lines) + 1):
|
||||
for pos in range(len(lines) + 1):
|
||||
lines = self.TEST.split('\n')
|
||||
lines.insert(pos, self.BAD_LINE)
|
||||
(marks, min, max) = get_marks(lines)
|
||||
|
@ -290,11 +287,11 @@ class TestBisectConflict(unittest.TestCase):
|
|||
marks = bisect(lines, marks, min, max,
|
||||
lambda l, m: self._update_func(l, m),
|
||||
lambda: self._test_func())
|
||||
for i in xrange(len(marks)):
|
||||
for i, mark in enumerate(marks):
|
||||
if i == pos:
|
||||
self.assertEqual(BAD, marks[i])
|
||||
self.assertEqual(BAD, mark)
|
||||
else:
|
||||
self.assertNotEqual(BAD, marks[i])
|
||||
self.assertNotEqual(BAD, mark)
|
||||
|
||||
class TestBisectRequired(unittest.TestCase):
|
||||
TEST = """#include <algorithm>
|
||||
|
@ -310,8 +307,7 @@ class TestBisectRequired(unittest.TestCase):
|
|||
|
||||
def _update_func(self, lines, marks):
|
||||
self.lines = []
|
||||
for i in xrange(len(marks)):
|
||||
mark = marks[i]
|
||||
for i, mark in enumerate(marks):
|
||||
if mark <= TEST_ON:
|
||||
self.lines.append(lines[i])
|
||||
else:
|
||||
|
@ -335,7 +331,7 @@ class TestBisectRequired(unittest.TestCase):
|
|||
|
||||
def test_required(self):
|
||||
lines = self.TEST.split('\n')
|
||||
for pos in xrange(len(lines) + 1):
|
||||
for pos in range(len(lines) + 1):
|
||||
lines = self.TEST.split('\n')
|
||||
lines.insert(pos, self.REQ_LINE)
|
||||
(marks, min, max) = get_marks(lines)
|
||||
|
@ -343,11 +339,11 @@ class TestBisectRequired(unittest.TestCase):
|
|||
marks = bisect(lines, marks, min, max,
|
||||
lambda l, m: self._update_func(l, m),
|
||||
lambda: self._test_func())
|
||||
for i in xrange(len(marks)):
|
||||
for i, mark in enumerate(marks):
|
||||
if i == pos:
|
||||
self.assertEqual(GOOD, marks[i])
|
||||
self.assertEqual(GOOD, mark)
|
||||
else:
|
||||
self.assertNotEqual(GOOD, marks[i])
|
||||
self.assertNotEqual(GOOD, mark)
|
||||
|
||||
unittest.main()
|
||||
|
||||
|
|
Loading…
Reference in a new issue