mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
25 lines
882 B
Python
25 lines
882 B
Python
from core.constants import SIGS
|
|
|
|
|
|
def get_ref_regex_for_sig(sig):
|
|
"""Utility function to get the regex string for a SIG reference for a named SIG. If no match is found, None will be returned."""
|
|
|
|
for s in SIGS:
|
|
if s.name.upper() == sig.upper():
|
|
return s.ref_regex
|
|
return None
|
|
|
|
|
|
def get_sig_name_from_comment_name(sig):
|
|
"""Utility function to get the name of a SIG 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 s in SIGS:
|
|
if any(n.upper() == sig.upper() for n in s.comment_names):
|
|
return s.name
|
|
return None
|
|
|
|
|
|
# Regex matching any SIG's "comment name", i.e. how it may be referred to in spot comments
|
|
ANY_SIG_REGEX = r"(" + r"|".join(n for s in SIGS for n in s.comment_names) + r")"
|