Skip to content
Snippets Groups Projects
Commit ba03a419 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

compare: use new `join_escaped` util to make sure we take dots into account

parent 174b25cc
No related branches found
No related tags found
2 merge requests!45Cleanups,!40clone git too
......@@ -6,7 +6,7 @@
import click
from poulpe.benchmarks import LEGACY_RESULTS_COMPARISON
from poulpe.utils import escape_string, split_unescape
from poulpe.utils import join_escaped, split_unescape
from . import get_data
......@@ -28,8 +28,8 @@
for key in headers_keys:
value = get_value(key, result)
if value is not None:
key = ".".join(key)
key = join_escaped(key, ".")
if key in ignored_dimensions:
continue
headers.append((key, value))
......@@ -32,8 +32,8 @@
if key in ignored_dimensions:
continue
headers.append((key, value))
variant_cmp_key = ".".join(compare_key)
variant_cmp_key = join_escaped(compare_key, ".")
variants = result["benchmark"].get("variants", {})
for key, value in sorted(variants.items()):
key = f"benchmark.variants.{key}"
......@@ -80,8 +80,7 @@
dispatched[(headers, compare_key)].append(r)
for (_h, comp_key), some_results in dispatched.items():
# XXX util for `escaped_join`
sort_by = ".".join(escape_string(k, ".") for k in comp_key)
sort_by = join_escaped(comp_key, ".")
sort_key = sort_keys.get(sort_by)
if sort_key is not None:
......
# Useful common code
import re
from typing import List
from typing import Iterable, List
def escape_string(s: str, chars: str, escape: str = "\\") -> str:
......@@ -11,6 +11,12 @@
return s
def join_escaped(to_join: Iterable[str], chars: str, escape: str = "\\") -> str:
"""Concatenate all strings in `to_join`, separating them with `chars`,
after escaping each char in `chars`."""
return chars.join(escape_string(s, chars, escape) for s in to_join)
def split_unescape(s: str, delim: str, escape: str = "\\") -> List[str]:
"""Split a string along `delim`, only if not escaped by `escape`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment