Merge commit '2ed4c1dac7' into development

This commit is contained in:
Dan Hawkins 2018-02-12 14:04:25 +00:00
commit 7649c2ad30
3 changed files with 66 additions and 0 deletions

17
versionstamping/.project Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>versionstamping</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python35</pydev_property>
</pydev_project>

View file

@ -0,0 +1,41 @@
import argparse
import sys
import shutil
from builtins import FileNotFoundError
def main(argv):
parser = argparse.ArgumentParser(description="Look for version number pattern in file and replace with autobuild version number")
# Call once arguments to allow or disallow something
parser.add_argument('-f', '--filetoconvert', help='The file to convert')
parser.add_argument('-p', '--pattern', default='1.30000.0.0', help='The pattern to search for and replace')
parser.add_argument('-s', '--substitute', help='The new version number that will substitute the pattern')
args = parser.parse_args(argv)
filetoconvert = args.filetoconvert
pattern = args.pattern
substitute = args.substitute
print("Converting incidences of {0} with {1} in file: {2}\n".format(pattern, substitute, filetoconvert))
filecopy = filetoconvert + ".orig"
try:
shutil.move(filetoconvert, filecopy)
except FileNotFoundError:
print("Could not find file: {0}\n".format(filetoconvert))
return 1
with open(filetoconvert, 'x') as f:
with open(filecopy,'r') as c:
fileread = c.read()
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
converted = fileread.replace(pattern, substitute)
#print ("DEBUG: %s "%converted)
print("Confirmed %s instances of %s post-conversion"%(converted.count(substitute),substitute))
f.write(converted)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))