MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / parse_message

Function parse_message

tensorflow/python/framework/error_interpolation.py:51–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

49
50
51def 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
83def _compute_device_summary_from_list(name, device_assignment_list, prefix=""):

Callers 1

interpolateFunction · 0.85

Calls 4

matchMethod · 0.45
appendMethod · 0.45
groupMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected