All checks were successful
Run apocalypse tests / Explore-Gitea-Actions (push) Successful in 10s
33 lines
739 B
Python
33 lines
739 B
Python
import re
|
|
|
|
from logzero import logger
|
|
|
|
|
|
def check_pgroup(pgroup):
|
|
if pgroup is None:
|
|
return pgroup
|
|
pgroup = str(pgroup)
|
|
if re.match(r"^p\d{5}$", pgroup, re.I):
|
|
return pgroup.lower()
|
|
if re.match(r"^\d{5}$", pgroup):
|
|
return "p" + pgroup
|
|
msg = f"Pgroup {pgroup} supplied in incorrect format. Proper format 'pXXXXX', X is a digit"
|
|
logger.error(msg)
|
|
raise SystemExit(msg)
|
|
|
|
|
|
def get_run_from_pth(pth):
|
|
return re.search(r"run(\d+)", pth).group(1)
|
|
|
|
|
|
def get_acq_from_pth(pth):
|
|
return re.search(r"acq(\d+)", pth).group(1)
|
|
|
|
|
|
def get_pgroup_from_pth(pth):
|
|
return re.search(r"data/p(\d+)", pth).group(1)
|
|
|
|
|
|
def get_es_from_pth(pth):
|
|
return re.search(r"sf/([^/]+)/data", pth).group(1)
|