SMB-119 - Not barfing when no substitions occurred
This commit is contained in:
parent
5cac7a574b
commit
fa989ef12f
1 changed files with 5 additions and 2 deletions
|
|
@ -26,15 +26,18 @@ def main(argv):
|
||||||
print("Could not find file: {0}\n".format(filetoconvert))
|
print("Could not find file: {0}\n".format(filetoconvert))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
count = 0
|
||||||
with open(filetoconvert, 'x') as f:
|
with open(filetoconvert, 'x') as f:
|
||||||
with open(filecopy,'r') as c:
|
with open(filecopy,'r') as c:
|
||||||
fileread = c.read()
|
fileread = c.read()
|
||||||
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
|
print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern))
|
||||||
converted = fileread.replace(pattern, substitute)
|
converted = fileread.replace(pattern, substitute)
|
||||||
#print ("DEBUG: %s "%converted)
|
count = converted.count(substitute)
|
||||||
print("Confirmed %s instances of %s post-conversion"%(converted.count(substitute),substitute))
|
print("Confirmed %s instances of %s post-conversion"%(count,substitute))
|
||||||
f.write(converted)
|
f.write(converted)
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue