Initial curated EventLens source from 0d80d3b38dfb817285481665b9e71e4b8a0656a0
This commit is contained in:
commit
663ea8c829
85 files changed
+12395
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
_VERSION_PATTERN = re.compile(r"^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$")
|
||||
_REVISION_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
||||
_VERSION_FILE = Path(__file__).resolve().parents[2] / "VERSION"
|
||||
LOCAL_REVISION = "local"
|
||||
|
||||
|
||||
def read_version() -> str:
|
||||
value = _VERSION_FILE.read_text(encoding="utf-8").strip()
|
||||
if not _VERSION_PATTERN.fullmatch(value):
|
||||
raise RuntimeError("Invalid EventLens VERSION file")
|
||||
return value
|
||||
|
||||
|
||||
def read_revision() -> str:
|
||||
value = os.environ.get("EVENTLENS_REVISION", "")
|
||||
if _REVISION_PATTERN.fullmatch(value):
|
||||
return value
|
||||
return LOCAL_REVISION
|
||||
|
||||
|
||||
VERSION = read_version()
|
||||
Reference in new issue
Block a user