Parses the message. Splits the message into separators and tags. Tags are named tuples representing the string {{type name}} and they are separated by separators. For example, in "123{{node Foo}}456{{node Bar}}789", there are two tags and three separators. The separators are the numeric cha
(message)
| 49 | |
| 50 | |
| 51 | def parse_message(message): |
| 52 | """Parses the message. |
| 53 | |
| 54 | Splits the message into separators and tags. Tags are named tuples |
| 55 | representing the string {{type name}} and they are separated by |
| 56 | separators. For example, in "123{{node Foo}}456{{node Bar}}789", there are |
| 57 | two tags and three separators. The separators are the numeric characters. |
| 58 | |
| 59 | Args: |
| 60 | message: String to parse |
| 61 | |
| 62 | Returns: |
| 63 | (list of separator strings, list of _ParseTags). |
| 64 | |
| 65 | For example, if message is "123{{node Foo}}456" then this function |
| 66 | returns (["123", "456"], [_ParseTag("node", "Foo")]) |
| 67 | """ |
| 68 | seps = [] |
| 69 | tags = [] |
| 70 | pos = 0 |
| 71 | while pos < len(message): |
| 72 | match = re.match(_INTERPOLATION_PATTERN, message[pos:]) |
| 73 | if match: |
| 74 | seps.append(match.group(1)) |
| 75 | tags.append(_ParseTag(match.group(3), match.group(4))) |
| 76 | pos += match.end() |
| 77 | else: |
| 78 | break |
| 79 | seps.append(message[pos:]) |
| 80 | return seps, tags |
| 81 | |
| 82 | |
| 83 | def _compute_device_summary_from_list(name, device_assignment_list, prefix=""): |
no test coverage detected