Source code for modalysis.core.expression

"""Expression field parsing utilities."""

[docs] def parse_expression_field(expression_field: str) -> dict[str, str]: """Parse `LABEL: VALUE; ...` expression text into uppercase mapping.""" expression_by_label = {} if not expression_field: return expression_by_label for part in expression_field.split(";"): cleaned_part = part.strip() if not cleaned_part or ":" not in cleaned_part: continue label, value = cleaned_part.split(":", 1) normalized_label = label.strip().upper() normalized_value = value.strip().upper() if not normalized_label or not normalized_value: continue expression_by_label[normalized_label] = normalized_value return expression_by_label