-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #552 from TriBITSPub/429-deprecation-2
- Loading branch information
Showing
38 changed files
with
401 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# | ||
# Run this in a subdir to replace all occurrences of INCLUDE_DIRECTORIES with | ||
# TRIBITS_INCLUDE_DIRECTORIES (and lower-case versions). Take into account | ||
# token boundaries so will not replace in the middle of a token. | ||
# | ||
# Run as: | ||
# | ||
# $ cd <some-base-dir> | ||
# $ <this-script-dir>/replace_include_directories_r.sh | ||
# | ||
|
||
_SCRIPT_DIR=`echo $0 | sed "s/\(.*\)\/.*replace_include_directories_r.sh/\1/g"` | ||
#echo $_SCRIPT_DIR | ||
|
||
echo | ||
echo "Replacing INCLUDE_DIRECTORIES with TRIBITS_INCLUDE_DIRECTORIES in all CMakeList.txt and *.cmake files ..." | ||
echo | ||
|
||
find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t INCLUDE_DIRECTORIES -r TRIBITS_INCLUDE_DIRECTORIES -f {} \; | ||
|
||
echo | ||
echo "Replacing include_directories with tribits_include_directories in all CMakeList.txt and *.cmake files ..." | ||
echo | ||
|
||
find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t include_directories -r tribits_include_directories -f {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/env python3 | ||
|
||
usageHelp = r""" | ||
Replace a given string with another string in a file (but only touch the file | ||
if there were changes). | ||
""" | ||
|
||
|
||
def getCmndLineOptions(): | ||
from argparse import ArgumentParser, RawDescriptionHelpFormatter | ||
|
||
clp = ArgumentParser(description=usageHelp, | ||
formatter_class=RawDescriptionHelpFormatter) | ||
|
||
clp.add_argument( | ||
"-s", dest="stringToReplace", required=True, | ||
help="String to repalce" ) | ||
|
||
clp.add_argument( | ||
"-r", dest="replacementString", required=True, | ||
help="Replacement string" ) | ||
|
||
clp.add_argument( | ||
"-f", dest="inputFile", required=True, | ||
help="Input file (and also output if -o <file> not specified)" ) | ||
|
||
clp.add_argument( | ||
"-o", dest="outputFile", default="", | ||
help="Input file (and also output if -o <file> not specified)" ) | ||
|
||
options = clp.parse_args(sys.argv[1:]) | ||
|
||
if options.outputFile == "": | ||
options.outputFile = options.inputFile | ||
|
||
return options | ||
|
||
|
||
# | ||
# Main() | ||
# | ||
|
||
if __name__ == '__main__': | ||
|
||
import sys | ||
|
||
inOptions = getCmndLineOptions() | ||
|
||
with open(inOptions.inputFile, 'r') as file: | ||
lines = file.readlines() | ||
|
||
fileWasChanged = False | ||
newLines = [] | ||
for line in lines: | ||
newLine = line.replace(inOptions.stringToReplace, inOptions.replacementString) | ||
if newLine != line: | ||
fileWasChanged = True | ||
newLines.append(newLine) | ||
|
||
if (fileWasChanged or inOptions.outputFile != inOptions.inputFile): | ||
with open(inOptions.outputFile, 'w') as file: | ||
file.writelines(newLines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/env python3 | ||
|
||
usageHelp = r""" | ||
Replace a given token string with another string in a file (but only touch the | ||
file if there were changes). | ||
This will only match complete tokens that match the regex: | ||
([^A-Za-z0-9_])|^)<token-to-replace)[^A-Za-z0-9_] | ||
""" | ||
|
||
|
||
def getCmndLineOptions(): | ||
from argparse import ArgumentParser, RawDescriptionHelpFormatter | ||
|
||
clp = ArgumentParser(description=usageHelp, | ||
formatter_class=RawDescriptionHelpFormatter) | ||
|
||
clp.add_argument( | ||
"-t", dest="tokenToReplace", required=True, | ||
help="Token to repalce" ) | ||
|
||
clp.add_argument( | ||
"-r", dest="replacementString", required=True, | ||
help="Replacement string" ) | ||
|
||
clp.add_argument( | ||
"-f", dest="inputFile", required=True, | ||
help="Input file (and also output if -o <file> not specified)" ) | ||
|
||
clp.add_argument( | ||
"-o", dest="outputFile", default="", | ||
help="Input file (and also output if -o <file> not specified)" ) | ||
|
||
options = clp.parse_args(sys.argv[1:]) | ||
|
||
if options.outputFile == "": | ||
options.outputFile = options.inputFile | ||
|
||
return options | ||
|
||
|
||
# | ||
# Main() | ||
# | ||
|
||
if __name__ == '__main__': | ||
|
||
import sys, re | ||
|
||
inOptions = getCmndLineOptions() | ||
|
||
beginLineTokenPattern = re.compile( | ||
r'^' + inOptions.tokenToReplace + r'([^A-Za-z0-9_])' ) | ||
midLineTokenPattern = re.compile( | ||
r'([^A-Za-z0-9_])' + inOptions.tokenToReplace + r'([^A-Za-z0-9_])' ) | ||
|
||
with open(inOptions.inputFile, 'r') as file: | ||
lines = file.readlines() | ||
|
||
fileWasChanged = False | ||
newLines = [] | ||
for line in lines: | ||
newLine = beginLineTokenPattern.sub( | ||
inOptions.replacementString + r'\1', | ||
line) | ||
newLine = midLineTokenPattern.sub( | ||
r'\1' + inOptions.replacementString + r'\2', | ||
newLine) | ||
if newLine != line: | ||
fileWasChanged = True | ||
newLines.append(newLine) | ||
|
||
if (fileWasChanged or inOptions.outputFile != inOptions.inputFile): | ||
with open(inOptions.outputFile, 'w') as file: | ||
file.writelines(newLines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/core/ExamplesUnitTests/PkgWithSubpkgsWithUserErrors/b/src/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -e | ||
# | ||
# Append a line to one or more files: | ||
# | ||
# append_line_to_files.sh <line-to-append> <file0> <file1> ... | ||
|
||
LINE_TO_APPEND=$1 ; shift | ||
|
||
for file in $@ ; do | ||
echo "Appending '$LINE_TO_APPEND' to file '${file}'" | ||
echo "$LINE_TO_APPEND" >> $file | ||
done |
Oops, something went wrong.