HMBXR5601-827 - Versionstamper.py is leaving excess files in package
This commit is contained in:
parent
c10055c58c
commit
b83050abc0
1 changed files with 6 additions and 12 deletions
|
|
@ -19,21 +19,15 @@ def main(argv):
|
|||
|
||||
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,'r') as c:
|
||||
fileread = c.read()
|
||||
|
||||
count = 0
|
||||
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)
|
||||
count = converted.count(substitute)
|
||||
print("Confirmed %s instances of %s post-conversion"%(count,substitute))
|
||||
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
|
||||
converted = fileread.replace(pattern, substitute)
|
||||
count = converted.count(substitute)
|
||||
print("Confirmed %s instances of %s post-conversion"%(count,substitute))
|
||||
f.write(converted)
|
||||
|
||||
if count == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue