tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gtest_filter_sets.py (1117B)


      1 #!/usr/bin/env python
      2 #
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 import os.path
      8 
      9 import yaml
     10 
     11 HERE = os.path.abspath(os.path.dirname(__file__))
     12 FILTER_SETS_FILE = os.path.join(HERE, "gtest_filter_sets.yml")
     13 
     14 
     15 def get(filter_set_name):
     16    """
     17    Retrieve the gtest filter associated with a specific filter set name.
     18    """
     19 
     20    with open(FILTER_SETS_FILE) as file:
     21        filter_set_data = yaml.safe_load(file)
     22 
     23    if filter_set_name in filter_set_data:
     24        return filter_set_data[filter_set_name].get("gtest_filter", None)
     25 
     26    return None
     27 
     28 
     29 def list():
     30    """
     31    Lists all available filter sets and their filters from the YAML file.
     32    """
     33    with open(FILTER_SETS_FILE) as file:
     34        filter_set_data = yaml.safe_load(file)
     35 
     36    print(f"Filter sets from {FILTER_SETS_FILE}:")
     37    for key, value in filter_set_data.items():
     38        gtest_filter = value.get("gtest_filter", "No gtest filter defined")
     39        print(f"- {key}: {gtest_filter}")