From 71f3be3bee2e8a07f85594c02a9b44627b219e95 Mon Sep 17 00:00:00 2001 From: Leonard Sasse Date: Thu, 28 Mar 2024 14:34:04 +0100 Subject: [PATCH] tdf#158803 Remove E999: SyntaxError's and some other minor edits Change-Id: I32d75eb03b1f1fd011dcbc6950bf74800446a422 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165464 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas --- bin/dump-poolitems-values.py | 47 ++++++++++++++++------------ bin/extract-tooltip.py | 26 ++++++++-------- bin/find-duplicated-sids.py | 48 +++++++++++++++++------------ bin/find-most-repeated-functions.py | 27 ++++++++++------ 4 files changed, 85 insertions(+), 63 deletions(-) diff --git a/bin/dump-poolitems-values.py b/bin/dump-poolitems-values.py index c2c5f357e9fa..d7dcc920574a 100755 --- a/bin/dump-poolitems-values.py +++ b/bin/dump-poolitems-values.py @@ -5,7 +5,6 @@ # import subprocess -import sys macroNameToValue = dict() macroNameToOriginalLine = dict() @@ -39,36 +38,44 @@ with a.stdout as txt: for line in txt: line = line.strip() originalLine = line - if not line.startswith("#define "): continue + if not line.startswith("#define "): + continue # strip the '#define' off the front idx1 = line.find(" ") - line = line[idx1 : len(line)].strip() + line = line[idx1:len(line)].strip() # extract the name idx1 = line.find(" ") - if (idx1 == -1): continue - macroName = line[0 : idx1].strip() - line = line[idx1 : len(line)].strip() + if (idx1 == -1): + continue + macroName = line[0:idx1].strip() + line = line[idx1:len(line)].strip() # ignore internal stuff - if macroName.startswith("_"): continue + if macroName.startswith("_"): + continue # strip any trailing comments idx1 = line.find("//") if (idx1 != -1): - line = line[0 : idx1].strip() + line = line[0:idx1].strip() idx1 = line.find("/*") if (idx1 != -1): - line = line[0 : idx1].strip() - if len(line) == 0: continue + line = line[0:idx1].strip() + if len(line) == 0: + continue # strip brackets - if line[0] == "(": line = line[1:] - if line[len(line)-1] == ")": line = line[0:len(line)-1] + if line[0] == "(": + line = line[1:] + if line[len(line)-1] == ")": + line = line[0:len(line)-1] macroValue = line.strip() # ignore macros that #define strings, not interested in those - if (macroValue.find("\"") != -1): continue + if (macroValue.find("\"") != -1): + continue # ignore the multiline macros - if (macroValue.find("\\") != -1): continue + if (macroValue.find("\\") != -1): + continue # check for redefinitions if macroNameToValue.has_key(macroName): - print "Redefinition:\n\t", macroNameToOriginalLine[macroName], "\n\t" , originalLine + print("Redefinition:\n\t", macroNameToOriginalLine[macroName], "\n\t", originalLine) else: macroNameToValue[macroName] = macroValue macroNameToOriginalLine[macroName] = originalLine @@ -81,11 +88,11 @@ for macroName in macroNameToValue: macroValue = extractMacroValue(macroName) macroValueToName[macroValue] = macroName except KeyError: - print "warning: could not decode macro ", macroName + print("warning: could not decode macro ", macroName) for macroValue in sorted(macroValueToName): macroName = macroValueToName[macroValue] - print repr(macroNameToValue[macroName]).rjust(5), " ", macroName - - - + print(repr(macroNameToValue[macroName]).rjust(5), " ", macroName) + + + diff --git a/bin/extract-tooltip.py b/bin/extract-tooltip.py index b313c9474af7..dffeee851595 100755 --- a/bin/extract-tooltip.py +++ b/bin/extract-tooltip.py @@ -20,26 +20,26 @@ def parseFile(filename): old_line = None for line in data: if len(line) > 0: - if(old_line != None): - print filename - #print("failed to parse line") - #print(old_line) + if old_line is not None: + print(filename) + # print("failed to parse line") + # print(old_line) line = old_line + line - print line + print(line) old_line = None split_line = regEx.split(line) - #print(split_line) - #print(urlparse.unquote(split_line[2])) - #print(split_line[4]) - if(old_line == None and split_line[4] == "" and split_line[3] != "0"): + # print(split_line) + # print(urlparse.unquote(split_line[2])) + # print(split_line[4]) + if (old_line is None and split_line[4] == "" and split_line[3] != "0"): print(line) print(split_line) old_line = line else: pairs[urlparse.unquote(split_line[2])] = split_line[4] assert(len(split_line) == 6) - #print data - #print(pairs) + # print data + # print(pairs) return pairs def parseFiles(dir): @@ -90,8 +90,8 @@ def writeOutFiles(dir, strings): file.write(value) file.write("\n") except UnicodeDecodeError: - print key - print value + print(key) + print(value) file.close() def main (args): diff --git a/bin/find-duplicated-sids.py b/bin/find-duplicated-sids.py index ebffce230b09..96b9aa4402ed 100755 --- a/bin/find-duplicated-sids.py +++ b/bin/find-duplicated-sids.py @@ -3,11 +3,11 @@ # Scan .hrc files for conflicting SID constants # -# This is not as easy as it sounds because some of the constants depend on other constants whose names do not start with SID_ +# This is not as easy as it sounds because some of the constants depend on other +# constants whose names do not start with SID_ # import subprocess -import sys sidNameToValue = dict() sidNameToOriginalLine = dict() @@ -41,28 +41,34 @@ with a.stdout as txt: line = line[idx1 : len(line)].strip() # extract the name idx1 = line.find(" ") - if (idx1 == -1): continue - sidName = line[0 : idx1].strip() - line = line[idx1 : len(line)].strip() + if (idx1 == -1): + continue + sidName = line[0:idx1].strip() + line = line[idx1:len(line)].strip() # strip any trailing comments idx1 = line.find("//") if (idx1 != -1): - line = line[0 : idx1].strip() + line = line[0:idx1].strip() idx1 = line.find("/*") if (idx1 != -1): - line = line[0 : idx1].strip() - if len(line) == 0: continue + line = line[0:idx1].strip() + if len(line) == 0: + continue # strip brackets - if line[0] == "(": line = line[1:] - if line[len(line)-1] == ")": line = line[0:len(line)-1] + if line[0] == "(": + line = line[1:] + if line[len(line)-1] == ")": + line = line[0:len(line)-1] sidTextValue = line.strip() # ignore the #define strings - if (sidTextValue.find("\"") != -1): continue + if (sidTextValue.find("\"") != -1): + continue # ignore the multiline macros - if (sidTextValue.find("\\") != -1): continue + if (sidTextValue.find("\\") != -1): + continue # check for redefinitions if sidName[0:4] == "SID_" and sidNameToValue.has_key(sidName): - print "Redefinition:\n\t", sidNameToOriginalLine[sidName], "\n\t" , originalLine + print("Redefinition:\n\t", sidNameToOriginalLine[sidName], "\n\t" , originalLine) else: sidNameToValue[sidName] = sidTextValue sidNameToOriginalLine[sidName] = originalLine @@ -77,16 +83,18 @@ with a.stdout as txt: except KeyError: sidNamesToIgnore.add(sidName) - # check for conflicts + # check for conflicts sidValueToName = dict() for sidName in sidNameToValue: - if sidName in sidNamesToIgnore: continue - if sidName[0:4] != "SID_": continue + if sidName in sidNamesToIgnore: + continue + if sidName[0:4] != "SID_": + continue sidValue = sidNameToValue[sidName] if sidValueToName.has_key(sidValue): - print "conflict:\n\t", sidNameToOriginalLine[sidName], "\n\t", sidNameToOriginalLine[sidValueToName[sidValue]] + print("conflict:\n\t", sidNameToOriginalLine[sidName], "\n\t", sidNameToOriginalLine[sidValueToName[sidValue]]) else: sidValueToName[sidValue] = sidName - - - + + + diff --git a/bin/find-most-repeated-functions.py b/bin/find-most-repeated-functions.py index 767f802406fb..dfdd0683130e 100755 --- a/bin/find-most-repeated-functions.py +++ b/bin/find-most-repeated-functions.py @@ -7,11 +7,17 @@ import subprocess from collections import defaultdict -# the odd bash construction here is because some of the .o files returned by find are not object files -# and I don't want xargs to stop when it hits an error -a = subprocess.Popen("find instdir/program/ -name *.so | xargs echo nm --radix=d --size-sort --demangle | bash", stdout=subprocess.PIPE, shell=True) +# the odd bash construction here is because some of the .o files returned +# by find are not object files and I don't want xargs to stop when it hits +# an error +a = subprocess.Popen( + ( + "find instdir/program/ -name *.so | " + "xargs echo nm --radix=d --size-sort --demangle | bash" + ), + stdout=subprocess.PIPE, shell=True) -#xargs sh -c "somecommand || true" +# xargs sh -c "somecommand || true" nameDict = defaultdict(int) with a.stdout as txt: @@ -28,15 +34,16 @@ for k, v in nameDict.iteritems(): cnt = 0 for k in sorted(list(sizeDict), reverse=True): - print k + print(k) for v in sizeDict[k]: - print v + print(v) cnt += 1 - if cnt > 100 : break + if cnt > 100: + break -#first = sorted(list(sizeDict))[-1] -#print first +# first = sorted(list(sizeDict))[-1] +# print first -#include/vcl/ITiledRenderable.hxx +# include/vcl/ITiledRenderable.hxx # why is gaLOKPointerMap declared inside this header?