Skip to content

Commit

Permalink
rename.py: assert the number of changes made
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore committed Nov 12, 2015
1 parent 9a6e308 commit d142b47
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os

def replace(name, branch, uid):
cnt = 0
for root, dir, files in os.walk("."):
yml = list(fnmatch.filter(files, "*.yml"))
xml = list(fnmatch.filter(files, "*.xml"))
Expand All @@ -14,14 +15,19 @@ def replace(name, branch, uid):
fname = os.path.join(root, f)
print "Setting space to '%s' in %s" % (name, fname)
for line in fileinput.input([fname], inplace=True):
line = line.replace("SPACENAME", name)
line = line.replace("SPACEBRANCH", name)
if "SPACE" in line:
cnt += 1
line = line.replace("SPACENAME", name)
line = line.replace("SPACEBRANCH", name)
print line,
for f in dkr:
fname = os.path.join(root, f)
for line in fileinput.input([fname], inplace=True):
line = line.replace("SPACEUSER", str(uid))
if "SPACE" in line:
cnt += 1
line = line.replace("SPACEUSER", str(uid))
print line,
return cnt

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand All @@ -34,5 +40,6 @@ def replace(name, branch, uid):
if not branch:
branch = name

replace(name, branch, ns.uid)
# This number will need to be updated when new changes are commited.
assert 19 == replace(name, branch, ns.uid)
print "Done. You may want to review and commit your changes now"

0 comments on commit d142b47

Please sign in to comment.