• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import annotations
6
7import re
8from typing import Optional
9
10_FLAG_TO_PATH_RE = re.compile(r"[-/\\:.]")
11
12
13def convert_flags_to_label(*flags: str, index: Optional[int] = None) -> str:
14  label = "default"
15  if flags:
16    label = _FLAG_TO_PATH_RE.sub("_", "_".join(flags).replace("--", ""))
17  if index is None:
18    return label
19  return f"{str(index).rjust(2,'0')}_{label}"
20