Guest User

Untitled

a guest
Feb 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import os
  2. import os.path
  3.  
  4. def get_clean_path(array):
  5. somestr = ""
  6. for x in range(0, len(array) - 1):
  7. somestr += array[x] + "\\"
  8. return somestr
  9.  
  10. def do_version_replace(current):
  11. oldlist = 0;
  12. with open(current) as f:
  13. oldlist = f.readlines();
  14.  
  15. for i, line in enumerate(oldlist):
  16. if "$$version$" in line:
  17. print("Replacing...")
  18. oldlist[i] = line.replace("$$version$", os.getenv('APPVEYOR_BUILD_VERSION', "XX.XX.XX"))
  19.  
  20. with open(current, 'w') as f:
  21. f.writelines(oldlist)
  22.  
  23. path = get_clean_path(os.path.realpath(__file__).split("\\"))
  24.  
  25. for dirpath, dirnames, filenames in os.walk(path):
  26. for filename in filenames:
  27. current = dirpath + "\\" + filename
  28. if filename.endswith(".cs"):
  29. print("Versioning: " + current)
  30. do_version_replace(current)
Add Comment
Please, Sign In to add comment