branding: Move from timestamp to build counter

This commit is contained in:
ave 2019-01-25 16:19:05 +03:00
parent eb1f1ff8ac
commit e57d1ff8ae
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
2 changed files with 24 additions and 5 deletions

View file

@ -1,25 +1,44 @@
#!/bin/env python3
import os
import sys
import time
fname = sys.argv[1]
persistdir = "/home/ave/distokrepos/versionlogs/"
def counterup():
# HACKY
cfname = persistdir + fname.split("/")[-1].replace(".patch", "")
if os.path.isfile(fname):
with open(cfname, 'r') as file:
countdata = file.read()
else:
countdata = 0
countdata = int(countdata) + 1
with open(cfname, 'w') as file:
file.write(str(countdata))
return countdata
# Read in the file
with open(fname, 'r') as file:
filedata = file.read()
timestamp = str(time.time()).split(".")[0]
buildnum = counterup()
name = "CutTheCord"
branch = "base"
if "customtheme" in sys.argv:
branch = "themed"
name += " Themed"
# name += " Themed"
# Replace the target string
filedata = filedata.replace("CTCBRANCH", branch)\
.replace("CTCTIMESTAMP", timestamp)\
.replace("CTCBUILD", buildnum)\
.replace("CTCNAME", name)
# Write the file out again