mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Minor fixes to python scripts by pycodestyle
This commit is contained in:
parent
64be2ad96c
commit
9e7c281e6e
@ -11,23 +11,23 @@ from scriptCommon import catchPath
|
||||
rootPath = os.path.join( catchPath, 'projects/SelfTest/Baselines' )
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
files = [os.path.join( rootPath, f ) for f in sys.argv[1:]]
|
||||
files = [os.path.join( rootPath, f ) for f in sys.argv[1:]]
|
||||
else:
|
||||
files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) )
|
||||
files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) )
|
||||
|
||||
|
||||
def approveFile( approvedFile, unapprovedFile ):
|
||||
justFilename = unapprovedFile[len(rootPath)+1:]
|
||||
if os.path.exists( unapprovedFile ):
|
||||
if os.path.exists( approvedFile ):
|
||||
os.remove( approvedFile )
|
||||
os.rename( unapprovedFile, approvedFile )
|
||||
print( "approved " + justFilename )
|
||||
else:
|
||||
print( "approval file " + justFilename + " does not exist" )
|
||||
justFilename = unapprovedFile[len(rootPath)+1:]
|
||||
if os.path.exists( unapprovedFile ):
|
||||
if os.path.exists( approvedFile ):
|
||||
os.remove( approvedFile )
|
||||
os.rename( unapprovedFile, approvedFile )
|
||||
print( "approved " + justFilename )
|
||||
else:
|
||||
print( "approval file " + justFilename + " does not exist" )
|
||||
|
||||
if len(files) > 0:
|
||||
for unapprovedFile in files:
|
||||
approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile )
|
||||
if files:
|
||||
for unapprovedFile in files:
|
||||
approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile )
|
||||
else:
|
||||
print( "no files to approve" )
|
||||
print( "no files to approve" )
|
||||
|
@ -25,7 +25,7 @@ class LineMapper:
|
||||
# TBD:
|
||||
# #if, #ifdef, comments after #else
|
||||
def mapLine( self, lineNo, line ):
|
||||
for idFrom, idTo in self.idMap.iteritems():
|
||||
for idFrom, idTo in self.idMap.items():
|
||||
r = re.compile("(.*)" + idFrom + "(.*)")
|
||||
|
||||
m = r.match( line )
|
||||
@ -38,7 +38,7 @@ class LineMapper:
|
||||
# print("[{0}] originalNs: '{1}' - closing".format(lineNo, originalNs))
|
||||
# print( " " + line )
|
||||
# print( " 1:[{0}]\n 2:[{1}]\n 3:[{2}]\n 4:[{3}]\n 5:[{4}]".format( m.group(1), m.group(2), m.group(3), m.group(4), m.group(5) ) )
|
||||
if self.outerNamespace.has_key(originalNs):
|
||||
if originalNs in self.outerNamespace:
|
||||
outerNs, innerNs = self.outerNamespace[originalNs]
|
||||
return "{0}}}{1}{2}::{3}{4}{5}\n".format( m.group(1), m.group(2), outerNs, innerNs, m.group(4), m.group(5))
|
||||
m = nsRe.match( line )
|
||||
@ -47,7 +47,7 @@ class LineMapper:
|
||||
# print("[{0}] originalNs: '{1}'".format(lineNo, originalNs))
|
||||
# print( " " + line )
|
||||
# print( " 1:[{0}]\n 2:[{1}]\n 3:[{2}]\n 4:[{3}]".format( m.group(1), m.group(2), m.group(3), m.group(4) ) )
|
||||
if self.outerNamespace.has_key(originalNs):
|
||||
if originalNs in self.outerNamespace:
|
||||
outerNs, innerNs = self.outerNamespace[originalNs]
|
||||
return "{0}{1} {{ namespace {2}{3}{4}\n".format( m.group(1), outerNs, innerNs, m.group(3), m.group(4) )
|
||||
|
||||
|
@ -4,19 +4,20 @@ from __future__ import print_function
|
||||
import os
|
||||
from scriptCommon import catchPath
|
||||
|
||||
changedFiles = 0
|
||||
|
||||
def isSourceFile( path ):
|
||||
return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" )
|
||||
|
||||
def fixAllFilesInDir( dir ):
|
||||
changedFiles = 0
|
||||
for f in os.listdir( dir ):
|
||||
path = os.path.join( dir,f )
|
||||
if os.path.isfile( path ):
|
||||
if isSourceFile( path ):
|
||||
fixFile( path )
|
||||
if fixFile( path ):
|
||||
changedFiles += 1
|
||||
else:
|
||||
fixAllFilesInDir( path )
|
||||
return changedFiles
|
||||
|
||||
def fixFile( path ):
|
||||
f = open( path, 'r' )
|
||||
@ -41,8 +42,10 @@ def fixFile( path ):
|
||||
f2.write( line )
|
||||
f2.close()
|
||||
os.remove( altPath )
|
||||
return True
|
||||
return False
|
||||
|
||||
fixAllFilesInDir(catchPath)
|
||||
changedFiles = fixAllFilesInDir(catchPath)
|
||||
if changedFiles > 0:
|
||||
print( "Fixed " + str(changedFiles) + " file(s)" )
|
||||
else:
|
||||
|
@ -7,7 +7,6 @@ import io
|
||||
import sys
|
||||
import re
|
||||
import datetime
|
||||
import string
|
||||
from glob import glob
|
||||
|
||||
from scriptCommon import catchPath
|
||||
@ -34,7 +33,7 @@ def generate(v):
|
||||
}
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
arg = string.lower(arg)
|
||||
arg = arg.lower()
|
||||
if arg == "noimpl":
|
||||
globals['includeImpl'] = False
|
||||
print( "Not including impl code" )
|
||||
@ -82,7 +81,7 @@ def generate(v):
|
||||
if m:
|
||||
header = m.group(1)
|
||||
headerPath, sep, headerFile = header.rpartition( "/" )
|
||||
if not headerFile in seenHeaders:
|
||||
if headerFile not in seenHeaders:
|
||||
if headerFile != "tbc_text_format.h" and headerFile != "clara.h":
|
||||
seenHeaders.add( headerFile )
|
||||
if headerPath == "internal" and path.endswith("internal/"):
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import urllib2
|
||||
@ -41,7 +43,6 @@ for line in lines:
|
||||
pass
|
||||
elif line.startswith( "Date:"):
|
||||
dates.append( line[5:].lstrip() )
|
||||
pass
|
||||
elif line == "" and prevLine == "":
|
||||
pass
|
||||
else:
|
||||
@ -58,7 +59,7 @@ for line in lines:
|
||||
else:
|
||||
messages.append( line2 )
|
||||
|
||||
print "All changes between {0} and {1}:\n".format( dates[-1], dates[0] )
|
||||
print("All changes between {0} and {1}:\n".format( dates[-1], dates[0] ))
|
||||
|
||||
for line in messages:
|
||||
print line
|
||||
print(line)
|
||||
|
@ -15,7 +15,7 @@ def runAndCapture( args ):
|
||||
line = ""
|
||||
while True:
|
||||
out = child.stdout.read(1)
|
||||
if out == '' and child.poll() != None:
|
||||
if out == '' and child.poll():
|
||||
break
|
||||
if out != '':
|
||||
if out == '\n':
|
||||
|
@ -12,7 +12,6 @@
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
from scriptCommon import catchPath
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
@ -20,6 +19,8 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from scriptCommon import catchPath
|
||||
|
||||
# Configuration:
|
||||
|
||||
minTocEntries = 4
|
||||
@ -431,7 +432,7 @@ def updateDocumentToCMain():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
paths = args.Input if len(args.Input) > 0 else [documentsDefault]
|
||||
paths = args.Input if args.Input else [documentsDefault]
|
||||
|
||||
changedFiles = updateDocumentToC(paths=paths, min_toc_len=args.minTocEntries, verbose=args.verbose)
|
||||
|
||||
|
@ -31,7 +31,6 @@ def get_hash(path):
|
||||
|
||||
def update_control(path):
|
||||
v = Version()
|
||||
ver_string = v.getVersionString()
|
||||
|
||||
# Update control
|
||||
lines = []
|
||||
@ -48,7 +47,6 @@ def update_control(path):
|
||||
def update_portfile(path, header_hash, licence_hash):
|
||||
print('Updating portfile')
|
||||
v = Version()
|
||||
ver_string = v.getVersionString()
|
||||
|
||||
# Update portfile
|
||||
lines = []
|
||||
|
@ -41,7 +41,7 @@ def uploadFiles():
|
||||
'save': True
|
||||
})
|
||||
|
||||
if 'status' in response and not 'compiler_error' in response:
|
||||
if 'status' in response and 'compiler_error' not in response:
|
||||
return True, response['url']
|
||||
else:
|
||||
return False, response
|
||||
|
Loading…
Reference in New Issue
Block a user