cutthecord/patches/branding/addpatch.py

28 lines
566 B
Python
Raw Normal View History

2019-01-25 12:48:05 +00:00
#!/bin/env python3
import sys
import time
fname = sys.argv[1]
# Read in the file
with open(fname, 'r') as file:
filedata = file.read()
timestamp = str(time.time()).split(".")[0]
name = "CutTheCord"
branch = "base"
if "customtheme" in sys.argv:
branch = "themed"
name += " Themed"
# Replace the target string
filedata = filedata.replace("CTCBRANCH", branch)\
.replace("CTCTIMESTAMP", timestamp)\
.replace("CTCNAME", name)
# Write the file out again
with open(fname.replace(".patch", "-custom.patch"), 'w') as file:
file.write(filedata)