MCPcopy Create free account
hub / github.com/Delgan/loguru / caster

Function caster

tests/test_parse.py:125–128  ·  view source on GitHub ↗
(groups)

Source from the content-addressed store, hash-verified

123 regex = r"\[(?P<num>.*)\] \[(?P<val>.*)\] \[(?P<date>.*)\]"
124
125 def caster(groups):
126 groups["num"] = int(groups["num"])
127 groups["val"] = float(groups["val"])
128 groups["date"] = datetime.strptime(groups["date"], "%Y-%m-%d %H:%M:%S")
129
130 result = next(logger.parse(file, regex, cast=caster))
131 assert result == dict(num=123, val=1.1, date=datetime(2017, 3, 29, 11, 11, 11))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected