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 <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
parent
575ab78504
commit
71f3be3bee
4 changed files with 85 additions and 63 deletions
|
@ -5,7 +5,6 @@
|
|||
#
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
macroNameToValue = dict()
|
||||
macroNameToOriginalLine = dict()
|
||||
|
@ -39,17 +38,20 @@ 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()
|
||||
# extract the name
|
||||
idx1 = line.find(" ")
|
||||
if (idx1 == -1): continue
|
||||
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):
|
||||
|
@ -57,18 +59,23 @@ with a.stdout as txt:
|
|||
idx1 = line.find("/*")
|
||||
if (idx1 != -1):
|
||||
line = line[0:idx1].strip()
|
||||
if len(line) == 0: continue
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,18 +20,18 @@ def parseFile(filename):
|
|||
old_line = None
|
||||
for line in data:
|
||||
if len(line) > 0:
|
||||
if(old_line != None):
|
||||
print filename
|
||||
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"):
|
||||
if (old_line is None and split_line[4] == "" and split_line[3] != "0"):
|
||||
print(line)
|
||||
print(split_line)
|
||||
old_line = line
|
||||
|
@ -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):
|
||||
|
|
|
@ -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,7 +41,8 @@ with a.stdout as txt:
|
|||
line = line[idx1 : len(line)].strip()
|
||||
# extract the name
|
||||
idx1 = line.find(" ")
|
||||
if (idx1 == -1): continue
|
||||
if (idx1 == -1):
|
||||
continue
|
||||
sidName = line[0:idx1].strip()
|
||||
line = line[idx1:len(line)].strip()
|
||||
# strip any trailing comments
|
||||
|
@ -51,18 +52,23 @@ with a.stdout as txt:
|
|||
idx1 = line.find("/*")
|
||||
if (idx1 != -1):
|
||||
line = line[0:idx1].strip()
|
||||
if len(line) == 0: continue
|
||||
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
|
||||
|
@ -80,11 +86,13 @@ with a.stdout as txt:
|
|||
# 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
|
||||
|
||||
|
|
|
@ -7,9 +7,15 @@
|
|||
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"
|
||||
|
||||
|
@ -28,11 +34,12 @@ 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
|
||||
|
|
Loading…
Reference in a new issue