From f0a48e3115938809f0ceec133f3c850a707e3f58 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 16 Sep 2020 09:04:26 +0200 Subject: kconfig model: json import --- lib/loader.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'lib/loader.py') diff --git a/lib/loader.py b/lib/loader.py index 3f0662e..14b7853 100644 --- a/lib/loader.py +++ b/lib/loader.py @@ -13,6 +13,7 @@ import hashlib import kconfiglib from multiprocessing import Pool from .utils import running_mean, soft_cast_int +from frozendict import frozendict logger = logging.getLogger(__name__) @@ -1953,8 +1954,9 @@ class KConfigAttributes: experiments.append((config_path, attr_path)) kconf = kconfiglib.Kconfig(kconfig_path) + self.kconf = kconf - self.symbols = sorted( + self.symbol_names = sorted( map( lambda sym: sym.name, filter( @@ -1964,17 +1966,22 @@ class KConfigAttributes: ) ) - self.data = list() + self.choice_names = sorted(map(lambda choice: choice.name, kconf.choices)) + + self.symbol = kconf.syms + self.choice = dict() + for choice in kconf.choices: + self.choice[choice.name] = choice - config_vectors = set() + self.data = list() for config_path, attr_path in experiments: kconf.load_config(config_path) with open(attr_path, "r") as f: attr = json.load(f) - config_vector = tuple( - map(lambda sym: kconf.syms[sym].tri_value == 2, self.symbols) - ) - config_vectors.add(config_vector) - self.data.append((config_vector, attr)) + config = dict.fromkeys(self.symbol_names, False) + for sym in self.symbol_names: + if kconf.syms[sym].tri_value == 2: + config[sym] = True + self.data.append((frozendict(config), attr)) -- cgit v1.2.3