MCPcopy Create free account
hub / github.com/ActiveState/code / translate

Method translate

recipes/Python/578138_gprof2dotpy/recipe-578138.py:838–850  ·  view source on GitHub ↗

Extract a structure from a match object, while translating the types in the process.

(self, mo)

Source from the content-addressed store, hash-verified

836 _float_re = re.compile(r'^\d+\.\d+$')
837
838 def translate(self, mo):
839 """Extract a structure from a match object, while translating the types in the process."""
840 attrs = {}
841 groupdict = mo.groupdict()
842 for name, value in groupdict.items():
843 if value is None:
844 value = None
845 elif self._int_re.match(value):
846 value = int(value)
847 elif self._float_re.match(value):
848 value = float(value)
849 attrs[name] = (value)
850 return Struct(attrs)
851
852 _cg_header_re = re.compile(
853 # original gprof header

Callers 4

parse_function_entryMethod · 0.95
parse_cycle_entryMethod · 0.95
name_replaceFunction · 0.45
convertFunction · 0.45

Calls 3

StructClass · 0.70
itemsMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected