Created
May 28, 2014 11:56
-
-
Save barkady/f220018784c0567a66e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
from random import randint | |
def IncreaseDefine(define, lines): | |
for idx, item in enumerate(lines): | |
if define in item: | |
tmp_str = item.split() | |
tmp_str[2] = str(int(tmp_str[2])+1)+"\n" | |
item = ' '.join(tmp_str) | |
line[idx] = item | |
return int(tmp_str[2]) | |
def ResetDefine(define, lines): | |
for idx, item in enumerate(lines): | |
if define in item: | |
tmp_str = item.split() | |
tmp_str[2] = "0\n" | |
item = ' '.join(tmp_str) | |
line[idx] = item | |
fo = open("src\\config.h", "r+") | |
print "Name of the file: ", fo.name | |
line = fo.readlines() | |
rand = randint(1,5) | |
for a in range(0, rand): | |
IncreaseDefine('#define VERSION_REVISION', line) | |
if IncreaseDefine('#define VERSION_BUILD', line)%100 == 0: | |
if IncreaseDefine('#define VERSION_MINOR', line) == 10: | |
ResetDefine('#define VERSION_MINOR', line) | |
IncreaseDefine('#define VERSION_MAJOR', line) | |
fo.seek(0) | |
for idx, item in enumerate(line): | |
fo.write(item) | |
fo.truncate() | |
fo.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment