Files
2125_GCE/codex_lineage/epoch_mapper.py
T

20 lines
536 B
Python
Raw Normal View History

import re
from .lineage_model import EpochInfo
def parse_epoch(epoch_str: str) -> EpochInfo:
epoch_str = str(epoch_str).strip().lower()
match = re.match(r'v?(\d+)(?:\.(\d+))?(?:-([a-z]+))?', epoch_str)
if match:
major = int(match.group(1))
minor = int(match.group(2)) if match.group(2) else 0
stability = match.group(3) if match.group(3) else "stable"
else:
major = 1
minor = 0
stability = "stable"
return EpochInfo(major=major, minor=minor, stability=stability)