20 lines
536 B
Python
Executable File
20 lines
536 B
Python
Executable File
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)
|