Commit ffeeabf2 authored by Rosen Matev's avatar Rosen Matev 🌲
Browse files

Merge branch 'erodrigu-valid-line-name' into 'master'

Clearer validation of selection line names, HLT and Sprucing

See merge request !1172
parents 05176c76 ab785742
Pipeline #3295897 passed with stages
in 5 minutes and 2 seconds
......@@ -41,6 +41,10 @@ from PyConf.application import (
)
from PyConf.utilities import ConfigurationError
#: Regular expression (compiled) defining the valid selection line names
SELECTION_LINE_NAME_PATTERN = re.compile(
r'^(Hlt[12]|Spruce)[A-Za-z0-9_]+Line$')
ONLINE = 'Online'
# "forward" some useful functions from PyConf.application
......@@ -725,14 +729,10 @@ def run_reconstruction(options, make_reconstruction, public_tools=[]):
return config
#: Regular expression (compiled) defining the valid line names
HLT_LINE_NAME_PATTERN = re.compile(r'^(Hlt[12]|Spruce)[A-Za-z0-9_]+Line$')
def valid_name(name):
"""Return True if name follows the HLT line name conventions."""
"""Return True if name follows the selection line (HLT, Sprucing) name conventions."""
try:
return HLT_LINE_NAME_PATTERN.match(name) is not None
return SELECTION_LINE_NAME_PATTERN.match(name) is not None
except TypeError:
return False
......@@ -794,7 +794,8 @@ def register_line_builder(registry):
def wrapper(wrapped):
name = _get_param_default(wrapped, 'name')
if not valid_name(name):
raise ValueError('{!r} is not a valid HLT line name'.format(name))
raise ValueError(
'{!r} is not a valid selection line name!'.format(name))
add_line_to_registry(registry, name, wrapped)
# TODO return a wrapped function that checks the return type is DecisionLine
return wrapped
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment