Modelo terminado
El script (ver entrada anterior IronPython) como lo estoy utilizando. (usar el plugin de inserción del source code no fue tan sencillo)
1: def matchversion(folder, major, minor, build):
2: import os3: import re4: import datetime
5: today = datetime.datetime.today()6: calculatedVersion = (today.year * 12 + today.month) * 100 + today.day7: for root, dirs, files in os.walk(folder):
8: for file in [f for f in files if f == "AssemblyInfo.cs"]:9: pattern = '(AssemblyVersion\(\"(\d*|\*)\.(\d*|\*)\.(\d*|\*)\.(\d*|\*)\"\))'10: version = 'AssemblyVersion("' + str(major) + '.' + str(minor) + '.' + str(build) + '.' + str(calculatedVersion) + '")'11: arch = open(root + file)
12: bytes = arch.read()
13: replaced = re.sub(pattern, version, bytes)14: arch.close()
15: arch = open(root + file, 'w')
16: bytes = arch.write(replaced)
17: arch.close()
0 comentarios: