mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
trace_cmd: more robust event fields parsing
The default paraser can now handle spaces in field values (but not field names).
This commit is contained in:
parent
6159711a05
commit
1c146e3ce7
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from wlauto.utils.misc import isiterable
|
from wlauto.utils.misc import isiterable
|
||||||
from wlauto.utils.types import numeric
|
from wlauto.utils.types import numeric
|
||||||
@ -133,10 +134,12 @@ def default_body_parser(event, text):
|
|||||||
the value into a numeric type, and failing that, keep it as string.
|
the value into a numeric type, and failing that, keep it as string.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
kv_pairs = [e.split('=', 1) for e in text.split()]
|
parts = [e.rsplit(' ', 1) for e in text.strip().split('=')]
|
||||||
new_values = {k: try_convert_to_numeric(v)
|
parts = [p.strip() for p in chain.from_iterable(parts)]
|
||||||
for (k, v) in kv_pairs}
|
if not len(parts) % 2:
|
||||||
event.fields.update(new_values)
|
i = iter(parts)
|
||||||
|
for k, v in zip(i, i):
|
||||||
|
event.fields[k] = v
|
||||||
|
|
||||||
|
|
||||||
def regex_body_parser(regex, flags=0):
|
def regex_body_parser(regex, flags=0):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user