bin/convwatch.py | 2 +- bin/find-german-comments | 10 ++++------ bin/refcount_leak.py | 2 +- bin/update_pch_bisect | 38 +++++++++++++++++--------------------- 4 files changed, 23 insertions(+), 29 deletions(-)
New commits: commit 96ffaadbcd3010515b2465f7f87b599909db5913 Author: Leonard Sasse <l.sa...@fz-juelich.de> AuthorDate: Fri Mar 29 06:19:45 2024 +0100 Commit: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> CommitDate: Tue Jun 25 08:14:53 2024 +0200 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.lauhakan...@libreoffice.org> Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> diff --git a/bin/convwatch.py b/bin/convwatch.py index 93082186f319..25920b7343c8 100644 --- a/bin/convwatch.py +++ b/bin/convwatch.py @@ -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: diff --git a/bin/find-german-comments b/bin/find-german-comments index 251f4f77f270..de1ed9481fca 100755 --- a/bin/find-german-comments +++ b/bin/find-german-comments @@ -61,7 +61,6 @@ class Parser: """ Extracts the source code comments. """ - linenum = 0 if self.args.verbose: print("processing file '%s'... " % 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(" - Error: Missing path %s - " % 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 " % baseDir) directory_allowlist[baseDir] = 2 elif not globalscan: diff --git a/bin/refcount_leak.py b/bin/refcount_leak.py index de98d065a2ac..d0b8cd502f7c 100755 --- a/bin/refcount_leak.py +++ b/bin/refcount_leak.py @@ -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:] diff --git a/bin/update_pch_bisect b/bin/update_pch_bisect index 271cbc88ff1b..71072303efdc 100755 --- a/bin/update_pch_bisect +++ b/bin/update_pch_bisect @@ -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(' ')))) 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(' ') - for pos in xrange(len(lines) + 1): + for pos in range(len(lines) + 1): lines = self.TEST.split(' ') 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(' ') - for pos in xrange(len(lines) + 1): + for pos in range(len(lines) + 1): lines = self.TEST.split(' ') 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()