Options: fix verify_keys breaking options containing lists of dicts
This commit is contained in:
parent
62391d3074
commit
0dc714f947
|
@ -191,8 +191,6 @@ def main(args=None, callback=ERmain):
|
||||||
if len(player_settings.values()) > 1:
|
if len(player_settings.values()) > 1:
|
||||||
important[option] = {player: value for player, value in player_settings.items() if
|
important[option] = {player: value for player, value in player_settings.items() if
|
||||||
player <= args.yaml_output}
|
player <= args.yaml_output}
|
||||||
elif len(player_settings.values()) > 0:
|
|
||||||
important[option] = player_settings[1]
|
|
||||||
else:
|
else:
|
||||||
logging.debug(f"No player settings defined for option '{option}'")
|
logging.debug(f"No player settings defined for option '{option}'")
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ class VerifyKeys:
|
||||||
@classmethod
|
@classmethod
|
||||||
def verify_keys(cls, data):
|
def verify_keys(cls, data):
|
||||||
if cls.valid_keys:
|
if cls.valid_keys:
|
||||||
|
data = set(data)
|
||||||
dataset = set(word.casefold() for word in data) if cls.valid_keys_casefold else set(data)
|
dataset = set(word.casefold() for word in data) if cls.valid_keys_casefold else set(data)
|
||||||
extra = dataset - cls.valid_keys
|
extra = dataset - cls.valid_keys
|
||||||
if extra:
|
if extra:
|
||||||
|
@ -269,7 +270,7 @@ class OptionDict(Option, VerifyKeys):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_any(cls, data: typing.Dict[str, typing.Any]) -> OptionDict:
|
def from_any(cls, data: typing.Dict[str, typing.Any]) -> OptionDict:
|
||||||
if type(data) == dict:
|
if type(data) == dict:
|
||||||
cls.verify_keys(set(data))
|
cls.verify_keys(data)
|
||||||
return cls(data)
|
return cls(data)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
||||||
|
@ -307,7 +308,7 @@ class OptionList(Option, VerifyKeys):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_any(cls, data: typing.Any):
|
def from_any(cls, data: typing.Any):
|
||||||
if type(data) == list:
|
if type(data) == list:
|
||||||
cls.verify_keys(set(data))
|
cls.verify_keys(data)
|
||||||
return cls(data)
|
return cls(data)
|
||||||
return cls.from_text(str(data))
|
return cls.from_text(str(data))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue