1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import sys
- from pprint import pprint
- import re
- import datetime
- VERSION_PATTERN = re.compile(r'^PLUGIN_VERSION\s+=\s+"([^"]+)"$', re.MULTILINE)
- if __name__ == "__main__":
- channel = sys.argv[2] if len(sys.argv) == 3 else "stable"
- now = datetime.datetime.now()
- date = now.strftime("%d.%m.%Y - %H:%M:%S")
- # Addon
- with open("src/consts.py", "r") as f:
- version_match = VERSION_PATTERN.search(f.read())
- if version_match:
- VERSION = version_match.group(1)
- else:
- VERSION = "0.0.0"
- content = ""
- with open("addon_template.xml", "r") as f:
- content = f.read()
- with open("addon.xml", "w") as f:
- f.write(
- content
- .replace("%RELEASE%", "" if channel == "stable" else "_beta")
- .replace("%CHANNEL%", channel)
- .replace("%NEWLINE%", "\n")
- .replace("%VERSION%", VERSION)
- .replace("%DATE%", date)
- )
- # Settings
- content = ""
- with open("settings_template.xml", "r") as f:
- content = f.read()
- with open("resources/settings.xml", "w") as f:
- f.write(content
- .replace("%RELEASE%", "" if channel == "stable" else "_beta")
- .replace("%CHANNEL%", channel)
- .replace("%NEWLINE%", "\n")
- .replace("%VERSION%", VERSION)
- .replace("%DATE%", date))
- content = ""
- with open(sys.argv[1], "r") as f:
- content = f.read()
- content = content.replace("%RELEASE%", channel)
- content = re.sub(r"\nfrom ((?:utils|viewids|watchdog|consts|compressedcookielib|portal|api|playerwatcher).*)", "", content)
- content = re.sub(r"\nimport ((?:utils|viewids|watchdog|consts|compressedcookielib|portal|api|playerwatcher).*)", "", content)
- with open(sys.argv[1], "w") as f:
- f.write(content)
|