Skip to content

Commit

Permalink
I do love my specifications-based terminological pedantry.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Jul 24, 2024
1 parent 5a9598c commit 6996788
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions robot-server/robot_server/service/notifications/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
_TOPIC_BASE = TopicName("robot-server")


def _is_valid_topic_name_segment(segment: str) -> bool:
"""Return whether a string is valid as a segment in an MQTT topic name."""
return not re.match("[/#+]", segment)
def _is_valid_topic_name_level(level: str) -> bool:
"""Return whether a string is valid as a level (segment) in an MQTT topic name."""
return not re.match("[/#+]", level)


MAINTENANCE_RUNS_CURRENT_RUN = TopicName(f"{_TOPIC_BASE}/maintenance_runs/current_run")
Expand All @@ -35,7 +35,7 @@ def _is_valid_topic_name_segment(segment: str) -> bool:
def client_data(key: str) -> TopicName:
"""Return the dynamic MQTT topic name for the given clientData key."""
base = f"{_TOPIC_BASE}/clientData"
if _is_valid_topic_name_segment(key):
if _is_valid_topic_name_level(key):
return TopicName(f"{base}/{key}")
else:
raise ValueError(
Expand Down

0 comments on commit 6996788

Please sign in to comment.