Ran autopep8.

This commit is contained in:
XhmikosR 2016-07-23 14:44:05 +03:00
parent 7ef02a7469
commit 07b43c6929
6 changed files with 233 additions and 233 deletions

View File

@ -578,6 +578,7 @@ class CppCheckFormatter(argparse.HelpFormatter):
'''
Properly formats multiline argument helps
'''
def _split_lines(self, text, width):
# this is the RawTextHelpFormatter._split_lines
if text.startswith('R|'):
@ -592,10 +593,10 @@ def ArgumentParser():
parser = argparse.ArgumentParser(formatter_class=CppCheckFormatter)
parser.add_argument('-t', '--template', metavar='<text>',
default='{callstack}: ({severity}) {message}',
help="R|Format the error messages. E.g.\n" \
"'{file}:{line},{severity},{id},{message}' or\n" \
"'{file}({line}):({severity}) {message}' or\n" \
"'{callstack} {message}'\n" \
help="R|Format the error messages. E.g.\n"
"'{file}:{line},{severity},{id},{message}' or\n"
"'{file}({line}):({severity}) {message}' or\n"
"'{callstack} {message}'\n"
"Pre-defined templates: gcc, vs, edit")
return parser
@ -619,7 +620,7 @@ def reportError(template, callstack=[], severity='', message='', id=''):
elif template == 'edit':
template = '{file} +{line}: {severity}: {message}'
# compute 'callstack}, {file} and {line} replacements
stack = ' -> '.join(['['+f+':'+str(l)+']' for (f,l) in callstack])
stack = ' -> '.join(['[' + f + ':' + str(l) + ']' for (f, l) in callstack])
file = callstack[-1][0]
line = str(callstack[-1][1])
# format message

View File

@ -198,7 +198,7 @@ def find_dump_files(paths):
for (top, subdirs, files) in os.walk(path):
for file in files:
if file.endswith('.dump'):
f = top+'/'+file
f = top + '/' + file
if not f in dumpfiles:
dumpfiles.append(f)
dumpfiles.sort()

View File

@ -150,7 +150,7 @@ def scanarchive(filepath, jobs):
removeLargeFiles('')
print(strfCurrTime('[%H:%M] cppcheck ' ) + filename)
print(strfCurrTime('[%H:%M] cppcheck ') + filename)
p = subprocess.Popen(
['nice',

View File

@ -10,11 +10,11 @@ FILE = None
BACKUPFILE = None
for arg in sys.argv[1:]:
if arg.startswith('--cmd='):
CMD = arg[arg.find('=')+1:]
CMD = arg[arg.find('=') + 1:]
elif arg.startswith('--expected='):
EXPECTED = arg[arg.find('=')+1:]
EXPECTED = arg[arg.find('=') + 1:]
elif arg.startswith('--file='):
FILE = arg[arg.find('=')+1:]
FILE = arg[arg.find('=') + 1:]
BACKUPFILE = FILE + '.bak'
elif arg == '--segfault':
SEGFAULT = True
@ -31,12 +31,12 @@ if FILE is None:
print('Abort: No --file')
sys.exit(1)
print('CMD='+CMD)
print('CMD=' + CMD)
if SEGFAULT:
print('EXPECTED=SEGFAULT')
else:
print('EXPECTED='+EXPECTED)
print('FILE='+FILE)
print('EXPECTED=' + EXPECTED)
print('FILE=' + FILE)
def runtool():
p = subprocess.Popen(CMD.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@ -57,7 +57,7 @@ def writefile(filename, filedata):
f.close()
def replaceandrun(what, filedata, i, line):
print(what + ' ' + str(i+1) + '/' + str(len(filedata)) + '..')
print(what + ' ' + str(i + 1) + '/' + str(len(filedata)) + '..')
bak = filedata[i]
filedata[i] = line
writefile(FILE, filedata)
@ -70,11 +70,11 @@ def replaceandrun(what, filedata, i, line):
return False
def replaceandrun2(what, filedata, i, line1, line2):
print(what + ' ' + str(i+1) + '/' + str(len(filedata)) + '..')
print(what + ' ' + str(i + 1) + '/' + str(len(filedata)) + '..')
bak1 = filedata[i]
bak2 = filedata[i+1]
bak2 = filedata[i + 1]
filedata[i] = line1
filedata[i+1] = line2
filedata[i + 1] = line2
writefile(FILE, filedata)
if runtool() == True:
print('pass')
@ -82,10 +82,10 @@ def replaceandrun2(what, filedata, i, line1, line2):
else:
print('fail')
filedata[i] = bak1
filedata[i+1] = bak2
filedata[i + 1] = bak2
def clearandrun(what, filedata, i1, i2):
print(what + ' ' + str(i1+1) + '/' + str(len(filedata)) + '..')
print(what + ' ' + str(i1 + 1) + '/' + str(len(filedata)) + '..')
filedata2 = list(filedata)
i = i1
while i <= i2 and i < len(filedata2):
@ -108,11 +108,11 @@ def removecomments(filedata):
def checkpar(line):
par = 0
for c in line:
if c=='(' or c=='[':
if c == '(' or c == '[':
par = par + 1
elif c==')' or c==']':
elif c == ')' or c == ']':
par = par - 1
if par<0:
if par < 0:
return False
return par == 0
@ -122,10 +122,10 @@ def combinelines(filedata):
lines = []
for i in range(len(filedata)-1):
for i in range(len(filedata) - 1):
fd1 = filedata[i].rstrip()
if fd1.endswith(','):
fd2 = filedata[i+1].lstrip()
fd2 = filedata[i + 1].lstrip()
if fd2 != '':
lines.append(i)
@ -141,10 +141,10 @@ def combinelines(filedata):
filedata2 = list(filedata)
for line in lines[i1:i2]:
filedata2[line] = filedata2[line].rstrip() + filedata2[line+1].lstrip()
filedata2[line+1] = ''
filedata2[line] = filedata2[line].rstrip() + filedata2[line + 1].lstrip()
filedata2[line + 1] = ''
if replaceandrun('combine lines', filedata2, lines[i1]+1, ''):
if replaceandrun('combine lines', filedata2, lines[i1] + 1, ''):
filedata = filedata2
lines[i1:i2] = []
i = i1
@ -153,8 +153,8 @@ def combinelines(filedata):
for line in lines:
fd1 = filedata[line].rstrip()
fd2 = filedata[line+1].lstrip()
replaceandrun2('combine lines', filedata, line, fd1+fd2, '')
fd2 = filedata[line + 1].lstrip()
replaceandrun2('combine lines', filedata, line, fd1 + fd2, '')
def removedirectives(filedata):
for i in range(len(filedata)):
@ -167,7 +167,7 @@ def removeblocks(filedata):
for i in range(len(filedata)):
strippedline = filedata[i].strip()
if len(strippedline)==0:
if len(strippedline) == 0:
continue
if ';{}'.find(strippedline[-1]) < 0:
continue
@ -210,7 +210,7 @@ def removeline(filedata):
if len(strippedline) == 0:
continue
if stmt and strippedline[-1]==';' and checkpar(line) and line.find('{')<0 and line.find('}')<0:
if stmt and strippedline[-1] == ';' and checkpar(line) and line.find('{') < 0 and line.find('}') < 0:
replaceandrun('remove line', filedata, i, '')
elif stmt and strippedline.find('{') > 0 and strippedline.find('}') == len(strippedline) - 1:

View File

@ -10,7 +10,7 @@ import sys
START = 0
PASSWORD = ''
for arg in sys.argv[1:]:
if len(arg)==1:
if len(arg) == 1:
START = '0123456789abcdefghijklmnopqrstuvwxyz'.find(arg)
if START < 0:
START = 0

View File

@ -32,7 +32,7 @@ if res is None:
rev1 = int(res.group(1))
rev2 = int(res.group(2))
if rev1>rev2 or rev1<10000 or rev2>20000 or rev2-rev1>500:
if rev1 > rev2 or rev1 < 10000 or rev2 > 20000 or rev2 - rev1 > 500:
print('range, aborting')
sys.exit(1)
@ -42,7 +42,7 @@ f = open('results.txt', 'wt')
f.write('\n')
f.close()
for rev in range(rev1,rev2):
for rev in range(rev1, rev2):
subprocess.call(['svn', 'revert', '-R', '.'])
subprocess.call(['svn', 'up', '-r' + str(rev)])
for vcxproj in glob.glob('*/*.vcxproj'):
@ -55,4 +55,3 @@ for rev in range(rev1,rev2):
f.write('\nREV ' + str(rev) + '\n')
f.write(comm[0].decode('utf-8'))
f.close()