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