mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
27 lines
964 B
Python
27 lines
964 B
Python
from core.constants import ACTIVITIES
|
|
|
|
|
|
def get_ref_regex_for_activity(activity):
|
|
"""Utility function to get the regex string for an activity reference for a named activity. If no match is
|
|
found, None will be returned."""
|
|
|
|
for a in ACTIVITIES:
|
|
if a.name.upper() == activity.upper():
|
|
return a.ref_regex
|
|
return None
|
|
|
|
|
|
def get_activity_name_from_comment_name(activity):
|
|
"""Utility function to get the name of an activity from its "comment name". Generally these will be the same
|
|
but there are some cases (e.g. is "TOTA" Towers, Tiles or Toilets?) where we need to transform one to the
|
|
other."""
|
|
|
|
for a in ACTIVITIES:
|
|
if any(n.upper() == activity.upper() for n in a.comment_names):
|
|
return a.name
|
|
return None
|
|
|
|
|
|
# Regex matching any activity's "comment name", i.e. how it may be referred to in spot comments
|
|
ANY_ACTIVITY_REGEX = rf"({'|'.join(n for a in ACTIVITIES for n in a.comment_names)})"
|