From 0dc714f94790baf19f6479515391bd19148ac76b Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 15 Jan 2022 21:20:26 +0100 Subject: [PATCH] Options: fix verify_keys breaking options containing lists of dicts --- Generate.py | 2 -- Options.py | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Generate.py b/Generate.py index 295eb140..45902dc2 100644 --- a/Generate.py +++ b/Generate.py @@ -191,8 +191,6 @@ def main(args=None, callback=ERmain): if len(player_settings.values()) > 1: important[option] = {player: value for player, value in player_settings.items() if player <= args.yaml_output} - elif len(player_settings.values()) > 0: - important[option] = player_settings[1] else: logging.debug(f"No player settings defined for option '{option}'") diff --git a/Options.py b/Options.py index 637f28c6..e8b1b920 100644 --- a/Options.py +++ b/Options.py @@ -251,6 +251,7 @@ class VerifyKeys: @classmethod def verify_keys(cls, data): if cls.valid_keys: + data = set(data) dataset = set(word.casefold() for word in data) if cls.valid_keys_casefold else set(data) extra = dataset - cls.valid_keys if extra: @@ -269,7 +270,7 @@ class OptionDict(Option, VerifyKeys): @classmethod def from_any(cls, data: typing.Dict[str, typing.Any]) -> OptionDict: if type(data) == dict: - cls.verify_keys(set(data)) + cls.verify_keys(data) return cls(data) else: raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}") @@ -307,7 +308,7 @@ class OptionList(Option, VerifyKeys): @classmethod def from_any(cls, data: typing.Any): if type(data) == list: - cls.verify_keys(set(data)) + cls.verify_keys(data) return cls(data) return cls.from_text(str(data))