Function for reading the fields in a backpack **primitive**
(_fields: dict[str, dict[str, str]])
| 7 | |
| 8 | |
| 9 | def parse_prim_fields(_fields: dict[str, dict[str, str]]) -> tuple[str | None, str | None, str | None]: |
| 10 | """ |
| 11 | Function for reading the fields in a backpack **primitive** |
| 12 | """ |
| 13 | for key, value in _fields.items(): |
| 14 | prim_value, prim_name, prim_id = (None,) * 3 |
| 15 | if key == "NUM": |
| 16 | prim_value = value.get("value") |
| 17 | else: |
| 18 | prim_name = value.get("value") |
| 19 | prim_id = value.get("id") |
| 20 | |
| 21 | # There really should only be 1 item, and this function can only return for that item |
| 22 | return prim_value, prim_name, prim_id |
| 23 | return (None,) * 3 |
| 24 | |
| 25 | |
| 26 | class BpField(field.Field): |