#!/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)