From a5aac66caa35847227843be93be732e5f51265f8 Mon Sep 17 00:00:00 2001 From: Rocco Moretti Date: Wed, 15 Oct 2025 13:38:26 -0500 Subject: [PATCH] Add Python3 support for build scripts. Add the ability to run the python scripts needed by COMPILING.md/scripts/build/build_cmdline.win.sh --- cmake/scripts/BclCmakeFile.py | 54 ++++--- cmake/scripts/BclCmakeFile.pyc | Bin 7186 -> 0 bytes cmake/scripts/CheckCmakeLists.py | 12 +- scripts/build/build_cmdline.apple.sh | 4 +- scripts/build/build_cmdline.linux.sh | 4 +- scripts/build/build_cmdline.win.sh | 4 +- scripts/code/CodeFileUtils.py | 55 +++---- scripts/code/CodeFileUtils.pyc | Bin 32970 -> 0 bytes scripts/code/CreateNamespaceForwardHeaders.py | 145 +++++++++--------- 9 files changed, 146 insertions(+), 132 deletions(-) delete mode 100644 cmake/scripts/BclCmakeFile.pyc delete mode 100644 scripts/code/CodeFileUtils.pyc diff --git a/cmake/scripts/BclCmakeFile.py b/cmake/scripts/BclCmakeFile.py index fde4633105..dba7af292c 100644 --- a/cmake/scripts/BclCmakeFile.py +++ b/cmake/scripts/BclCmakeFile.py @@ -1,8 +1,14 @@ + +from __future__ import print_function + import string import os import sys import os.path -import cStringIO +try: + from io import StringIO +except: + from StringIO import StringIO # class represents a single SET(...) command from a CMakeLists file, optionally lower case class CmakeListSetCommand: @@ -27,7 +33,7 @@ def FromFile(self, lines, line_number_start): start_scope_pos = lines[line_number_start].find('(') self.line_number_end, end_scope_paren_pos = self.EndOfScope(lines, line_number_start, start_scope_pos) if end_scope_paren_pos < 0 or self.line_number_end < 0: - print "Unclosed parenthesis!" + print("Unclosed parenthesis!") return (-1) if self.line_number_end >= len(lines): self.line_number_end = len(lines) - 1 @@ -43,48 +49,48 @@ def FromFile(self, lines, line_number_start): if set_command_clean.find('.cpp') < 0 and (set_command_clean.find("SOURCES") < 0 or set_command_clean.find('${') > 0): # set command with no sources, not interesting return (-1) - + if end_scope_paren_pos != len(set_command_lines_clean[-1].rstrip()) - 1: - print str(line_number_start) + " " + str(start_scope_pos) \ + print(str(line_number_start) + " " + str(start_scope_pos) \ + " " + str(self.line_number_end) + " " + str(end_scope_paren_pos) \ - + " " + str(len(lines)) + " " + str(len(set_command_lines_clean[-1].rstrip()) - 1) - print "multiple commands on a single line not allowed, line: " + set_command_clean + + " " + str(len(lines)) + " " + str(len(set_command_lines_clean[-1].rstrip()) - 1)) + print("multiple commands on a single line not allowed, line: " + set_command_clean) return (-1) if set_command_clean != set_command: - print "could not parse set command: " + ''.join(set_command_lines_clean) + "\nbecause it contained comments or quotes" + print("could not parse set command: " + ''.join(set_command_lines_clean) + "\nbecause it contained comments or quotes") return (-1) # now we can finally parse the lines set_command_internal = set_command.strip()[start_scope_pos + 1:-1].replace('\n', ' ').replace('\t', ' ') - #print "set command, internal component: " + set_command_internal + #print("set command, internal component: " + set_command_internal) # make sure there were no comments or quotes in the set command if set_command.find('#') > 0 or set_command.find('"') > 0 or set_command.find("'") > 0: - print "Could not parse cmake set command with internal comments or quotes" + print("Could not parse cmake set command with internal comments or quotes") return (-1) set_command_tokens = set_command_internal.split(' ') set_command_tokens = [ token for token in set_command_tokens if len(token) > 0] self.variable = set_command_tokens[ 0] - for token_index in xrange(1, len(set_command_tokens)): + for token_index in range(1, len(set_command_tokens)): if set_command_tokens[token_index].endswith('.cpp'): - #print "adding source: " + set_command_tokens[token_index] + #print("adding source: " + set_command_tokens[token_index]) self.sources.add(set_command_tokens[token_index].replace('${CMAKE_CURRENT_SOURCE_DIR}/', '')) elif len(self.sources) == 0: - #print "other variables: " + set_command_tokens[token_index] + " in " + set_command_internal + #print("other variables: " + set_command_tokens[token_index] + " in " + set_command_internal) self.other_variables.append(set_command_tokens[token_index]) else: - #print "flag: " + set_command_tokens[token_index] + " in " + set_command_internal + #print("flag: " + set_command_tokens[token_index] + " in " + set_command_internal) self.flag_lines.append(set_command_tokens[token_index]) if len(self.sources) == 0 and (len(self.other_variables) or len(self.flag_lines)): - print "no sources in " + set_command_internal + print("no sources in " + set_command_internal) return (-1) - #print "sources: " + ','.join(self.sources) + #print("sources: " + ','.join(self.sources)) return self.line_number_end def Write(self, x): @@ -246,19 +252,19 @@ def CheckCmakeLists(directory, sources_dict, can_update): # warn the user and return if the sources could not be added if largest_set_command_index == -1: - print "Error: " + filename + ": Could not add sources because this file lacks a parseable set command that includes sources" + print ("Error: " + filename + ": Could not add sources because this file lacks a parseable set command that includes sources") return # warn the user if there is an ambiguous assignment of sources to a set command if len(all_set_command_blocks) > 1 and len(added_sources) > 0: - print "Warning: ambiguous assignment of new sources in " + filename + " to largest block of sources" + print("Warning: ambiguous assignment of new sources in " + filename + " to largest block of sources") if can_update: - # write the modified file to a cstringio object, then write that to a file + # write the modified file to a stringio object, then write that to a file # this is several times faster than writing directly to the file - out_file = cStringIO.StringIO() + out_file = StringIO() prev_line_start = 0 - for cmake_set_number in xrange(len(all_set_command_blocks)): + for cmake_set_number in range(len(all_set_command_blocks)): if(prev_line_start != all_set_command_blocks[cmake_set_number].line_number_start): out_file.write(''.join(lines[prev_line_start:all_set_command_blocks[cmake_set_number].line_number_start])) all_set_command_blocks[cmake_set_number].Write(out_file) @@ -274,12 +280,12 @@ def CheckCmakeLists(directory, sources_dict, can_update): # let the user know what was done if len(removed_sources): - print "Removing " + ','.join(removed_sources) + " from " + filename + print("Removing " + ','.join(removed_sources) + " from " + filename) if len(added_sources): - print "Adding " + ','.join(added_sources) + " to " + filename + print("Adding " + ','.join(added_sources) + " to " + filename) else: # will not update; just inform the user as to what would be added/removed if len(removed_sources): - print "Running in fix mode would remove " + ','.join(removed_sources) + " from " + filename + print("Running in fix mode would remove " + ','.join(removed_sources) + " from " + filename) if len(added_sources): - print "Running in fix mode would add " + ','.join(added_sources) + " to " + filename + print("Running in fix mode would add " + ','.join(added_sources) + " to " + filename) diff --git a/cmake/scripts/BclCmakeFile.pyc b/cmake/scripts/BclCmakeFile.pyc deleted file mode 100644 index a105bc7cb24a1f089b148b7af863928ac29a0bf9..0000000000000000000000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;t1Y?U!6eynIodbRkTOlUPUw|Akb6Ag<<+FZY1f7aWl7qJ`ws( z6j&g2^qT54%A-B+hZQuP3dF)4xD6I@@54&!3$7*l?FxHN{~u8tDvS6iQE->E zz;bR?qVLL^MKjo3&JS|QxtVlTBx%@6)&=(EB=wnB4WrrhEbC-wT-?Fgwcy#X=FJxQB#C&vn$U0>k#LMr7IXVl?_I`vGLs2Z6FM`8*n5F2k zT=l};&18GOvkxN1B-`mOYFe+eFRhr2)Sw%S z@lVI1sTxlMC1=`4(SqEdx*=*7THC~3No)eeTR%no#c7Shh}Da&aHPp)p9*xRq$Hd4 zn8HwL7lB#WDQCp*kpXA~w6qNHiNJIydfKO+ir+i0PH%=0-DDOzX2a8p4XXQX2w zOSbTYXqmW zp9fT3RP1K)z4F1u#v7SPpG4HLf=ZzypU+?I2(y*DadStSF8p6d<{>p^4X50BDSf6{ z=DIZ(MVyOb$gR2y?pc<@?zlVaOt@#=Nff(Z)-%qGKJ6}`(=zK$Vr>eeD$3caJNMK70dX$N#sB~S diff --git a/cmake/scripts/CheckCmakeLists.py b/cmake/scripts/CheckCmakeLists.py index a734f63ece..25ebb329ae 100755 --- a/cmake/scripts/CheckCmakeLists.py +++ b/cmake/scripts/CheckCmakeLists.py @@ -3,20 +3,22 @@ Created on Feb 19, 2011 This script checks CmakeLists for the bcl project, optionally updating CMakeLists.txt with new source files and removing -non-existent files. +non-existent files. @author: mendenjl ''' +from __future__ import print_function + import os import sys import os.path from BclCmakeFile import * -# print usage info +# print usage info def usage(): - print "\nusage: CheckCmakeLists.py bcl-path [-o]\n" - print "-o if given, update the CMakeLists" + print("\nusage: CheckCmakeLists.py bcl-path [-o]\n") + print("-o if given, update the CMakeLists") def main(): @@ -57,7 +59,7 @@ def main(): # does the cmake list file even exist yet? if source_directory not in cmake_list_paths.keys(): if len(directory_sources) > 0: - print source_directory + " needs a CMakeLists.txt file containing:\n" + '\n'.join(directory_sources) + '\n' + print(source_directory + " needs a CMakeLists.txt file containing:\n" + '\n'.join(directory_sources) + '\n') else: # open the cmake lists file CheckCmakeLists(source_directory, source_files_and_directories, should_update) diff --git a/scripts/build/build_cmdline.apple.sh b/scripts/build/build_cmdline.apple.sh index 795ac636fc..d48cba318c 100755 --- a/scripts/build/build_cmdline.apple.sh +++ b/scripts/build/build_cmdline.apple.sh @@ -7,9 +7,9 @@ BCL_DIRECTORY=`pwd` export TOOLCHAIN_ALIAS TOOLCHAIN BUILD_TYPE_ALIAS BCL_DIRECTORY mkdir -p build/${TOOLCHAIN_ALIAS}_${BUILD_TYPE_ALIAS} -python2 ./cmake/scripts/CheckCmakeLists.py ./ -o +python ./cmake/scripts/CheckCmakeLists.py ./ -o -python2 ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o +python ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o if [ -z "${SHARED+x}" ] ; then tcsh ./scripts/build/check_pump_make.csh -k static diff --git a/scripts/build/build_cmdline.linux.sh b/scripts/build/build_cmdline.linux.sh index 53624f8142..0da5acea4c 100755 --- a/scripts/build/build_cmdline.linux.sh +++ b/scripts/build/build_cmdline.linux.sh @@ -7,9 +7,9 @@ BCL_DIRECTORY=`pwd` export TOOLCHAIN_ALIAS TOOLCHAIN BUILD_TYPE_ALIAS BCL_DIRECTORY mkdir -p build/${TOOLCHAIN_ALIAS}_${BUILD_TYPE_ALIAS} -python2 ./cmake/scripts/CheckCmakeLists.py ./ -o +python ./cmake/scripts/CheckCmakeLists.py ./ -o -python2 ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o +python ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o if [ -z "${SHARED+x}" ] ; then tcsh ./scripts/build/check_pump_make.csh -k static diff --git a/scripts/build/build_cmdline.win.sh b/scripts/build/build_cmdline.win.sh index c5b411f2cc..18c5f57a0a 100755 --- a/scripts/build/build_cmdline.win.sh +++ b/scripts/build/build_cmdline.win.sh @@ -7,9 +7,9 @@ BCL_DIRECTORY=`pwd` export TOOLCHAIN_ALIAS TOOLCHAIN BUILD_TYPE_ALIAS BCL_DIRECTORY mkdir -p build/${TOOLCHAIN_ALIAS}_${BUILD_TYPE_ALIAS} -python2 ./cmake/scripts/CheckCmakeLists.py ./ -o +python ./cmake/scripts/CheckCmakeLists.py ./ -o -python2 ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o +python ./scripts/code/CreateNamespaceForwardHeaders.py ./ -o if [ -z "${SHARED+x}" ] ; then tcsh ./scripts/build/check_pump_make.csh -k static diff --git a/scripts/code/CodeFileUtils.py b/scripts/code/CodeFileUtils.py index 5a7fe3e44c..07ccf6113a 100644 --- a/scripts/code/CodeFileUtils.py +++ b/scripts/code/CodeFileUtils.py @@ -3,12 +3,15 @@ @brief Functions used in parsing code-files, some of which are bcl-specific @author: mendenjl ''' +from __future__ import print_function import sys import os -import cStringIO from curses.ascii import isspace, isalpha, isdigit -from string import lower +try: + from io import StringIO +except: + from StringIO import StringIO # write a string with a certain precision def strWithPrecision(number, precision): @@ -26,13 +29,13 @@ def Contains(listy, stringy): return i def findIndexStringStartingWith(listy, stringy, startPos = 0): - for i in xrange(max(startPos, 0), len(listy) , 1): + for i in range(max(startPos, 0), len(listy) , 1): if listy[i].startswith(stringy): return i return (-1) -def rfindIndexStringStartingWith(listy, stringy, startPos = sys.maxint): - for i in xrange(min(len(listy), startPos), 0, -1): +def rfindIndexStringStartingWith(listy, stringy, startPos = sys.maxsize): + for i in range(min(len(listy), startPos), 0, -1): if listy[i].startswith(stringy): return i return (-1) @@ -400,7 +403,7 @@ def findAllNonArrayVariablesAndIndices(line): i += 1 return tokens, listOIndices -# find all things that look like variables +# find all things that look like variables def findAllNonArrayVariables(line): return findAllNonArrayVariablesAndIndices(line) @@ -426,7 +429,7 @@ def findEndOfUncommentedCPPFunction(ourLines, startLine): break startLine += 1 if startLine == len(ourLines): - print "Unbalanced brackets in " + '\n'.join(ourLines) + "terminating " + print("Unbalanced brackets in " + '\n'.join(ourLines) + "terminating ") sys.exit(1) return startLine @@ -474,13 +477,13 @@ def walkToEndOfNumber(strn, startPos): i = last return i -ishex = [ isdigit(chr(x)) or (chr(x) >= 'a' and chr(x) <= 'f') or (chr(x) >= 'A' and chr(x) <= 'F') for x in xrange(256)] +ishex = [ isdigit(chr(x)) or (chr(x) >= 'a' and chr(x) <= 'f') or (chr(x) >= 'A' and chr(x) <= 'F') for x in range(256)] def walkToEndOfCPPNumber(strn, startPos): en = walkToEndOfNumber(strn, startPos) if en == startPos or en == len(strn) or not isalpha(strn[en]): return en - low = lower(strn[en]) + low = strn[en].lower() # handle floating point suffices if low == 'f' or low == 'd': @@ -493,17 +496,17 @@ def walkToEndOfCPPNumber(strn, startPos): en += 1 if en == len(strn) or not isalpha(strn[en]): return en - low = lower(strn[en]) + low = strn[en].lower() # handle integral suffices if low == 'u': en += 1 if en == len(strn): return en - low = lower(strn[en]) + low = strn[en].lower() if low == 'l': en += 1 - if en < len(strn) and lower(strn[en]) == 'l': + if en < len(strn) and strn[en].lower() == 'l': return en + 1 return en @@ -595,7 +598,7 @@ def walkToEndOfNextScope(strn, startPos):# assumes no comments or spaces parenDepth -= 1 endPos += 1 else: - print "no valid scope!: " + strn + print("no valid scope!: " + strn) sys.exit(1) return endPos @@ -678,7 +681,7 @@ def stripComments(ourLines): if(len(strings)): buffer += strings + '\n' walker = 0 - placer = cStringIO.StringIO() + placer = StringIO() inEscape = 0 if len(buffer): while walker + 1 < len(buffer): @@ -750,8 +753,8 @@ def stripComments(ourLines): placer.write(buffer[walker]) buffer = placer.getvalue() ourLines = buffer.split('\n') - ourLines = [ourLines[i].strip() for i in xrange(len(ourLines)) if ourLines[i] != None] - ourLines = [ourLines[i] for i in xrange(len(ourLines)) if len(ourLines[i]) > 0] + ourLines = [ourLines[i].strip() for i in range(len(ourLines)) if ourLines[i] != None] + ourLines = [ourLines[i] for i in range(len(ourLines)) if len(ourLines[i]) > 0] return(ourLines) def stripCommentsAndQuotes(ourLines): @@ -762,7 +765,7 @@ def stripCommentsAndQuotes(ourLines): if(len(strings)): buffer += strings + '\n' walker = 0 - placer = cStringIO.StringIO() + placer = StringIO() inEscape = 0 if len(buffer): while walker + 1 < len(buffer): @@ -830,8 +833,8 @@ def stripCommentsAndQuotes(ourLines): placer.write(buffer[walker]) buffer = placer.getvalue() ourLines = buffer.split('\n') - ourLines = [ourLines[i].strip() for i in xrange(len(ourLines)) if ourLines[i] != None] - ourLines = [ourLines[i] for i in xrange(len(ourLines)) if len(ourLines[i]) > 0] + ourLines = [ourLines[i].strip() for i in range(len(ourLines)) if ourLines[i] != None] + ourLines = [ourLines[i] for i in range(len(ourLines)) if len(ourLines[i]) > 0] return(ourLines) @@ -843,7 +846,7 @@ def stripMultilineComments(ourLines): if(len(strings)): buffer += strings + '\n' walker = 0 - placer = cStringIO.StringIO() + placer = StringIO() inEscape = 0 if len(buffer): while walker + 1 < len(buffer): @@ -917,8 +920,8 @@ def stripMultilineComments(ourLines): placer.write(buffer[walker]) buffer = placer.getvalue() ourLines = buffer.split('\n') - ourLines = [ourLines[i].strip() for i in xrange(len(ourLines)) if ourLines[i] != None] - ourLines = [ourLines[i] for i in xrange(len(ourLines)) if len(ourLines[i]) > 0] + ourLines = [ourLines[i].strip() for i in range(len(ourLines)) if ourLines[i] != None] + ourLines = [ourLines[i] for i in range(len(ourLines)) if len(ourLines[i]) > 0] return(ourLines) def isCommentBlockDelimitingLine(line): @@ -1007,7 +1010,7 @@ def getDoxyBlocksContainingTag(ourLines, tag): def getClassesAndStructs(ourLines): lines = stripComments(ourLines) lines = [ line.strip() for line in lines if (line.strip().startswith('struct ') or line.strip().startswith('class ')) and not line.strip().endswith(';')] - for i in xrange(len(lines)): + for i in range(len(lines)): if lines[i].startswith('class '): lines[i] = lines[i][6:] else: @@ -1024,7 +1027,7 @@ def getClassesAndStructs(ourLines): def extractStrings(ourLines, prep): ourStrings = [] - for i in xrange(len(ourLines)): + for i in range(len(ourLines)): if '\'' in ourLines[i] or '"' in ourLines[i]: walker = 0 lastStrEnd = 0 @@ -1099,12 +1102,12 @@ def getFilesFromDirectory(directory, suffix): def writeTwoLists(afile, prefix, vars, joiner, RHSs, suffix): if len(vars): endStr = suffix + prefix - afile.write(prefix + endStr.join([(str(vars[i]) + joiner + str(RHSs[i])) for i in xrange(len(vars))]) + suffix) + afile.write(prefix + endStr.join([(str(vars[i]) + joiner + str(RHSs[i])) for i in range(len(vars))]) + suffix) def writeOneList(afile, prefix, vars, suffix): if len(vars): endStr = suffix + prefix - afile.write(prefix + endStr.join([str(vars[i]) for i in xrange(len(vars))]) + suffix) + afile.write(prefix + endStr.join([str(vars[i]) for i in range(len(vars))]) + suffix) def writeOneSet(afile, prefix, vars, suffix): if len(vars): diff --git a/scripts/code/CodeFileUtils.pyc b/scripts/code/CodeFileUtils.pyc deleted file mode 100644 index 50ad40535e19409c270b570e75169faaea3da014..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32970 zcmd^o4U}A0ecydEt6j}{SKsn#ZP{AMmb8{Et!4ZnWJ%VSg@omm{8q9+SdvHcW~Gs4 zXLja|tP#i*B1kzQ387#Jr70f?F$8Expyj|hCg7YjEwpLULr(*x;q#CXNJ*j1X=$PT z{eJ)V-n^L|%QlSZX=`im-h1Eu{D1%d_rAB;9}W-x!N7I-f{XsU8^3qqCwyzxxxl#- zNIe&1T-kFckg zD9>|mz`%np=vU@C7Yw*yzIy{^7;;6=oga2VPQ?W-7*v~uF1SvaMJ^apX0Z!~m099~ z1VoCU+~9)imATOcBg(9F!3t$= za>1xFH@n~lWmdW1MrFoauu_@TF1SgVH7>YWnOj`2N|{?-Fs95}7pzuhoeS0|v)%=_ zC^PPYTa~%Z1#6Yr;DU9^Y;}@>0TSz=2XVjp7c&kxZrlpeTNG+DYL~D?{vXt7vK>px3~bs zm$=|A7u@ZFdt7j@3%0u8r7qa!g8N*s-32>bu+s(iyI_|KcDrDY3--ETp9>yv!G0IK z%moKraL@%Wcfo@$IOKwdTrlZ^!!9`Df`?t;yI{%%M_q8t1&_GkxC>t4f>*lWg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mXcZ;^hQ1fI&jIlDx&>_jwvVo* zzzI+Tto#lM=6HVKxnX@X&-}Rs@OQz4w3Og z1OUNt`gBk&oIY)@?8z|r03Q*eg^P7WD>moDLaD@85S&jA(hCxzb-0S~C-waapY8p{ zOlbV-G5(w>K2YWJ+iCs{Oja_X1@Et8vYyEXCYzbu!DJJYdzoxy@=_+$4*mp_`7JIClPJCa+`i3rwb&@H&zICL{uS;auH+Gi%<$5?!TMKdzieJ3GrobK>jXsA7k=+Og_QnX(pdz@`p@5&*Y0tzQN>M zO#X_=cbNPwlmE=*he$YZD)|}Sl$?)&w$D_9i{;`@5~AMP?#F#s{=X7;S91fofua6| z{rEkIpH;clx#8SU?z-F(l&{P6=lI{ETsAkFTbWy!>%;#GayRAHqh 2: - print "This makes no sense: " + line + print("This makes no sense: " + line) sys.exit(1) continue @@ -339,28 +342,28 @@ def extractFromNormalHeader(self, filenm): statement_type_is_class = False template_scope_depth = 0 in_statement = True - #print "templ start" + #print("templ start") elif line.startswith('typedef'): statement_type_is_typedef = True statement_type_is_template = False statement_type_is_class = False in_statement = True - #print "typedef start" + #print("typedef start") elif line.startswith('class ') or line.startswith('struct '): statement_type_is_typedef = False statement_type_is_template = False statement_type_is_class = True in_statement = True - #print "class start" + #print("class start") if in_statement and past_namespace: - print "Illegal statement after close of namespace: " + line + ' in ' + filenm + print("Illegal statement after close of namespace: " + line + ' in ' + filenm) sys.exit(1) else: in_statement_start = False if not in_statement: continue - #print "Start? " + str(in_statement_start) - #print "Statement: " + line + #print("Start? " + str(in_statement_start)) + #print("Statement: " + line) end_pos_start_looking = 0 @@ -393,7 +396,7 @@ def extractFromNormalHeader(self, filenm): end_pos_start_looking = endes statement_type_is_class = True elif len(next_word): - #print "templated function: " + str(end_pos_start_looking) + ' ' + str(endes) + ' ' + (last_statement + ' ' + line).strip().replace('\n', ' ') + #print("templated function: " + str(end_pos_start_looking) + ' ' + str(endes) + ' ' + (last_statement + ' ' + line).strip().replace('\n', ' ')) in_statement = False continue expected_indent = 2 * (len(self.namespaces) + template_scope_depth) @@ -420,7 +423,7 @@ def extractFromNormalHeader(self, filenm): elif statement_type_is_class: if line.find('<', end_pos_start_looking) >= 0 or line.find('(', end_pos_start_looking) >= 0: # partial specialization, no need to insert - #print "Partial specialization or function: " + last_statement.replace('\n', ' ') + line + #print("Partial specialization or function: " + last_statement.replace('\n', ' ') + line) in_statement = False continue @@ -442,7 +445,7 @@ def extractFromNormalHeader(self, filenm): else: end_pos_start_looking = semi_colon_pos last_statement += line[:end_pos_start_looking] - #print "Here 3: " + last_statement.replace('\n', ' ') + " " + str(statement_type_is_class) + #print("Here 3: " + last_statement.replace('\n', ' ') + " " + str(statement_type_is_class)) in_statement = False last_statement = last_statement.rstrip('\n ;:{') + ';' if len(last_statement) <= 1: @@ -452,12 +455,12 @@ def extractFromNormalHeader(self, filenm): if len(last_statement) <= 1: continue if statement_type_is_template: - if last_statement.find('BCL_API') >= 0: - print "Unnecessary to have BCL_API on line " + last_statement + " in " + filenm + if last_statement.find('BCL_API') >= 0: + print("Unnecessary to have BCL_API on line " + last_statement + " in " + filenm) elif statement_type_is_class and last_statement.find('BCL_API') < 0: - print "Missing BCL_API on line " + last_statement + " in " + filenm + print("Missing BCL_API on line " + last_statement + " in " + filenm) last_statement = last_statement.replace('BCL_API ', '') - #print "LS: " + last_statement.replace('\n', ' ') + #print("LS: " + last_statement.replace('\n', ' ')) name = last_statement.split(' ')[-1][:-1] full_statement = remove_extra_spaces(last_statement) @@ -474,18 +477,18 @@ def extractFromNormalHeader(self, filenm): def combine(self, other): if self.namespaces != other.namespaces: if len(other.templates) or len(other.classes): - print "cannot combine forward headers with different namespaces: " - print "should have: " + str(self.namespaces) + " but received: " + str(other.namespaces) + " from file: " + other.filename + print("cannot combine forward headers with different namespaces: ") + print("should have: " + str(self.namespaces) + " but received: " + str(other.namespaces) + " from file: " + other.filename) sys.exit(1) else: self.bcl_includes = self.bcl_includes.union(other.bcl_includes) self.std_includes = self.std_includes.union(other.std_includes) - for name, val in other.templates.iteritems(): + for name, val in other.templates.items(): if name not in self.templates: self.templates[ name] = val elif val.find('=') >= 0: - print "WARNING: You will need to manually remove the default template parameter from file " + other.filename + print("WARNING: You will need to manually remove the default template parameter from file " + other.filename) self.templates[ name] = val elif self.templates[ name].find('=') >= 0: pass @@ -495,7 +498,7 @@ def combine(self, other): old_leng = len(self.typedefs) self.typedefs.update(other.typedefs) if old_leng < len(self.typedefs): - print "WARNING: You should remove all namespace-level typedefs from " + other.filename + print("WARNING: You should remove all namespace-level typedefs from " + other.filename) def write(self, strm): term_filename = self.filename.split('/')[-1] @@ -533,7 +536,7 @@ def write(self, strm): strm.write(' ' * (indent - 2) + '/////////////////////\n') strm.write('\n') - for line in align_trailing_words([ y[1] for y in sorted(self.classes.iteritems())], 1, indent): + for line in align_trailing_words([ y[1] for y in sorted(self.classes.items())], 1, indent): strm.write(' ' * indent + line + '\n') if len(self.classes): @@ -544,7 +547,7 @@ def write(self, strm): strm.write(' ' * (indent - 2) + '//////////////////////\n') strm.write('\n') - for line in [ y[1] for y in sorted(self.templates.iteritems())]: + for line in [ y[1] for y in sorted(self.templates.items())]: strm.write(' ' * indent + line + '\n\n') strm.write(' ' * (indent - 2) + '//////////////\n') @@ -552,13 +555,13 @@ def write(self, strm): strm.write(' ' * (indent - 2) + '//////////////\n') strm.write('\n') - for line in align_trailing_words([ y[1] for y in sorted(self.typedefs.iteritems())], 1, indent): + for line in align_trailing_words([ y[1] for y in sorted(self.typedefs.items())], 1, indent): strm.write(' ' * indent + line + '\n') if len(self.typedefs): strm.write('\n') - for x in xrange(len(self.namespaces) - 1, -1, -1): + for x in range(len(self.namespaces) - 1, -1, -1): indent -= 2 strm.write(' ' * indent + '} // namespace ' + self.namespaces[x] + '\n') strm.write('\n') @@ -569,16 +572,16 @@ def updateDependencies(self): if len(self.typedefs) == 0 and len(self.templates) == 0: return - self.external_dependencies = getClassesFromOtherNamespacesDict(self.templates.itervalues()) + self.external_dependencies = getClassesFromOtherNamespacesDict(self.templates.values()) - for typedef, val in self.typedefs.iteritems(): + for typedef, val in self.typedefs.items(): new_dependencies = getClassesFromOtherNamespacesDict([val]) if len(new_dependencies): self.typedef_to_external_dependencies[typedef] = new_dependencies dictExtend(self.external_dependencies, new_dependencies) def deconvolute(self, otherFwds): - for typedef in self.typedefs.iterkeys(): + for typedef in self.typedefs.keys(): self.deconvoluteTypedef(typedef, otherFwds) self.std_includes = set() if 'std' in self.external_dependencies: @@ -588,7 +591,7 @@ def deconvolute(self, otherFwds): # remove things from the external dependency list that turned out not to be legitimate namespaces non_namespaces = [] - for namespace, classes in self.external_dependencies.iteritems(): + for namespace, classes in self.external_dependencies.items(): if namespace not in otherFwds: non_namespaces.append(namespace) for namespace in non_namespaces: @@ -598,7 +601,7 @@ def updateDependenciesFinal(self, otherFwds): symbols_to_check_dict = self.external_dependencies while len(symbols_to_check_dict): new_symbols_to_check_dict = {} - for namespace, classes in symbols_to_check_dict.iteritems(): + for namespace, classes in symbols_to_check_dict.items(): if namespace not in otherFwds: continue fwd_header = otherFwds[namespace] @@ -611,7 +614,7 @@ def updateDependenciesFinal(self, otherFwds): else: self.external_typedef_dependencies[namespace].add(name) symbols_to_check_dict = new_symbols_to_check_dict - for namespace, classes in self.external_typedef_dependencies.iteritems(): + for namespace, classes in self.external_typedef_dependencies.items(): self.external_dependencies[namespace] = self.external_dependencies[namespace].difference(classes) def get(self, strn): @@ -631,10 +634,10 @@ def getStdHeaders(self, strm): return strm def writeDependencies(self, strm, otherFwds): - #print "typedefs: " + str(self.typedefs) + " typedefs to extern: " + str(self.typedef_to_external_dependencies) - #print "external dependencies before: " + str(self.external_dependencies) + #print("typedefs: " + str(self.typedefs) + " typedefs to extern: " + str(self.typedef_to_external_dependencies)) + #print("external dependencies before: " + str(self.external_dependencies)) self.updateDependenciesFinal(otherFwds) - #print "external dependencies after: " + str(self.external_dependencies) + #print("external dependencies after: " + str(self.external_dependencies)) if len(self.external_dependencies) == 0: return False @@ -655,7 +658,7 @@ def writeDependencies(self, strm, otherFwds): strm.write('\n////////////////////////////////') strm.write('\n// class forward declarations //') strm.write('\n////////////////////////////////\n') - for namespace, classes in iter(sorted(self.external_dependencies.iteritems())): + for namespace, classes in iter(sorted(self.external_dependencies.items())): if len(classes) == 0: continue strm.write('\n namespace ' + namespace + '\n {') @@ -668,7 +671,7 @@ def writeDependencies(self, strm, otherFwds): strm.write('\n///////////////////////') strm.write('\n// external typedefs //') strm.write('\n////////////////////////\n') - for namespace, classes in iter(sorted(self.external_typedef_dependencies.iteritems())): + for namespace, classes in iter(sorted(self.external_typedef_dependencies.items())): if len(classes) == 0: continue strm.write('\n namespace ' + namespace + '\n {') @@ -690,7 +693,7 @@ def deconvoluteTypedef(self, strn, all_fwd_hdrs): symbols_to_check_dict = self.typedef_to_external_dependencies[strn] while len(symbols_to_check_dict): new_symbols_to_check_dict = {} - for namespace, class_names in symbols_to_check_dict.iteritems(): + for namespace, class_names in symbols_to_check_dict.items(): if namespace == 'std': continue fwd_header = all_fwd_hdrs[namespace] @@ -714,7 +717,7 @@ def deconvoluteTypedef(self, strn, all_fwd_hdrs): self.typedef_to_external_dependencies[strn][namespace].add(name) dictExtend(new_symbols_to_check_dict, fwd_header.typedef_to_external_dependencies[ name]) symbols_to_check_dict = new_symbols_to_check_dict - #print strn + " " + str(self.typedef_to_external_dependencies[ strn]) + #print(strn + " " + str(self.typedef_to_external_dependencies[ strn])) self.deconvoluted_typedefs.add(strn) @@ -735,13 +738,13 @@ def __init__(self, fname = "", read_all = False): self.ExtractFromFile(fname, read_all) def usage(): - print "\n" + \ + print("\n" + \ "usage: CreateNamespaceForwardHeaders.py bcl-path [options]\n" + \ "options:\n" + \ "-h/--help print this dialogue\n" + \ "-o/--output overwrite existing forward headers if necessary (default is to print them to screen)\n" + \ "-f/--force forces regeneration of all forward headers (e.g. ignore timestamps)\n" + \ - "-e/--existing augments the list of symbols with existing .fwd.hh files\n" + "-e/--existing augments the list of symbols with existing .fwd.hh files\n") sys.exit(1) def main(): @@ -758,7 +761,7 @@ def main(): force = False consider_old_fwd_headers = False - for i in xrange(1, len(arguments)): + for i in range(1, len(arguments)): if arguments[i] == '-h' or arguments[i] == '--help': usage() elif arguments[i] == '-o' or arguments[i] == '--output': @@ -768,18 +771,18 @@ def main(): elif arguments[i] == '-e' or arguments[i] == '--existing': consider_old_fwd_headers = True else: - print arguments[i] + " is not a valid option" + print(arguments[i] + " is not a valid option") usage() if not bcl_path.endswith('/'): bcl_path += '/' os.chdir(bcl_path) - + # read the copyright block global copyright_block copyright_block_file = os.path.abspath(bcl_path + "../../documentation/bcl_copyright.txt") if os.path.exists(bcl_path + "../../documentation/bcl_copyright.txt") \ else os.path.abspath(bcl_path + "documentation/bcl_copyright.txt") if not os.path.exists(copyright_block_file): - print "Cannot locate bcl copyright file at " + copyright_block_file + "! Exiting" + print("Cannot locate bcl copyright file at " + copyright_block_file + "! Exiting") sys.exit(-1) else: fl = open(copyright_block_file,'r') @@ -790,11 +793,11 @@ def main(): copyright_block.append('\n') # append an extra new line to separate the copyright block from other code copyright_block = ''.join(copyright_block) fl.close() - + if not os.path.exists('./build'): os.mkdir('./build') - # look for an existing file that denotes the last update times + # look for an existing file that denotes the last update times timestamp_file = 'build/.forward_header_update_time.txt' last_update_time = 0 if os.path.exists(timestamp_file): @@ -807,7 +810,7 @@ def main(): # flatten all headers out, so that the forward headers are inserted into the proper place all_headers = {} - for folder, files in all_headers_full.iteritems(): + for folder, files in all_headers_full.items(): namespace_folder_depth = 0 if folder.startswith('include/'): namespace_folder_depth += 1 @@ -824,7 +827,7 @@ def main(): else: all_headers[folder].extend(files) should_write_fwd_hdr = set() - for folder, files in all_headers.iteritems(): + for folder, files in all_headers.items(): namespace_folder_depth = 0 if folder != 'include': namespace_folder_depth = 1 @@ -834,7 +837,7 @@ def main(): if x.count('_') <= namespace_folder_depth: namespace_files.append(x) if len(namespace_files) != 1: - print "Unclear which file is the namespace header for " + folder + " among: " + str(namespace_files) + print("Unclear which file is the namespace header for " + folder + " among: " + str(namespace_files)) sys.exit(1) namespace_file = namespace_files[0][:-2] namespace = namespace_file.split('_')[-1] @@ -887,16 +890,16 @@ def main(): fwd_hdr.updateDependencies() generated_fwd_headers[ namespace] = fwd_hdr - for hdr in generated_fwd_headers.itervalues(): + for hdr in generated_fwd_headers.values(): hdr.deconvolute(generated_fwd_headers) - for namespace, namespace_fwd in generated_fwd_headers.iteritems(): + for namespace, namespace_fwd in generated_fwd_headers.items(): if namespace not in should_write_fwd_hdr: continue; direct = os.path.dirname(namespace_fwd.filename) - writer = cStringIO.StringIO() + writer = StringIO() namespace_fwd.write(writer) - writerd = cStringIO.StringIO() + writerd = StringIO() should_writed = namespace_fwd.writeDependencies(writerd, generated_fwd_headers) dfilename = namespace_fwd.filename[:-7] + '.depends.fwd.hh' if output: @@ -909,7 +912,7 @@ def main(): if lines == st: should_write = False if should_write: - print "Updating " + namespace_fwd.filename + print("Updating " + namespace_fwd.filename) ofile = open(namespace_fwd.filename, 'w') ofile.write(st) ofile.close() @@ -923,17 +926,17 @@ def main(): if st == lines: should_write = False if should_write: - print "Updating " + dfilename + print("Updating " + dfilename) ofile = open(dfilename, 'w') ofile.write(writerd.getvalue()) ofile.close() elif os.path.exists(dfilename): - print "Removing unnecessary dependency file: " + dfilename + print("Removing unnecessary dependency file: " + dfilename) os.remove(dfilename) else: - print namespace_fwd.filename + '\n' + writer.getvalue() + print(namespace_fwd.filename + '\n' + writer.getvalue()) if should_writed: - print dfilename + '\n' + writerd.getvalue() + print(dfilename + '\n' + writerd.getvalue()) if output: ofile = open(timestamp_file, 'w')