Created
August 8, 2021 07:37
-
-
Save rtsisyk/b04e1bbd6fa178eb473a0a07025a805c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
update_check_data = "src/fdroid/play/version.yaml|version:\s.+\+(\d+)|.|version:\s(.+)\+" | |
tag = "2021.08.08-7-android" | |
#### | |
import sys | |
import re | |
import logging | |
from pathlib import Path | |
logging.basicConfig(level=logging.DEBUG) | |
build_dir = Path('.') | |
filecode, codeex, filever, verex = update_check_data.split('|') | |
if filecode: | |
filecode = build_dir / filecode | |
if not filecode.is_file(): | |
logging.debug("UpdateCheckData file {0} not found in tag {1}".format(filecode, tag)) | |
sys.exit(1) | |
filecontent = filecode.read_text() | |
vercode = tag | |
if codeex: | |
m = re.search(codeex, filecontent) | |
if not m: | |
logging.error("codeex failed") | |
sys.exit(1) | |
vercode = m.group(1).strip() | |
if filever: | |
if filever != '.': | |
filever = build_dir / filever | |
if filever.is_file(): | |
filecontent = filever.read_text() | |
else: | |
logging.debug("UpdateCheckData file {0} not found in tag {1}".format(filever, tag)) | |
else: | |
filecontent = tag | |
version = tag | |
if verex: | |
m = re.search(verex, filecontent) | |
if m: | |
version = m.group(1) | |
logging.debug("UpdateCheckData found version {0} ({1})" | |
.format(version, vercode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment