Skip to content

Commit

Permalink
allowed parsing of *METADATA_LABEL post introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Dec 19, 2024
1 parent e50a2a7 commit 5a67c63
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pandablocks_ioc/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ async def introspect_panda(


def extract_label_from_metadata(block_name_number, field_name: str):
#
# Parse *METADATA.LABEL_<block><num> into "<block>" key and
# "<block><num>:LABEL" value
if block_name_number.startswith("*METADATA") and field_name.startswith("LABEL_"):
Expand Down Expand Up @@ -2101,6 +2100,21 @@ async def update(

for field, value in changes.values.items():
field = PandAName(field)
field = panda_to_epics_name(field)

if block_label := extract_label_from_metadata(
*field.split(":", maxsplit=1)
):
no_trailing_number_regex = r"\d*$"
block_label_no_number = (
f"{re.sub(no_trailing_number_regex, '', block_label)}:LABEL"
)
block_label = f"{block_label}:LABEL"

if block_label_no_number in all_records:
field = block_label_no_number
elif block_label in all_records:
field = block_label

if field not in all_records:
logging.error(
Expand Down

0 comments on commit 5a67c63

Please sign in to comment.