From 54e50f69e177c5d02a3d539b758e1e7a9889285e Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 14 Oct 2021 19:42:13 +0200 Subject: [PATCH] Options: various fixes to get_option_name falsely giving get_current_option_name instead. --- FactorioClient.py | 14 +++++++++----- Options.py | 10 ++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/FactorioClient.py b/FactorioClient.py index d9a4d856..8678434e 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -68,11 +68,15 @@ class FactorioContext(CommonContext): raise Exception("Cannot connect to a server with unknown own identity, " "bridge to Factorio first.") - await self.send_msgs([{"cmd": 'Connect', - 'password': self.password, 'name': self.auth, 'version': Utils.version_tuple, - 'tags': ['AP'], - 'uuid': Utils.get_unique_identifier(), 'game': "Factorio" - }]) + await self.send_msgs([{ + "cmd": 'Connect', + 'password': self.password, + 'name': self.auth, + 'version': Utils.version_tuple, + 'tags': ['AP'], + 'uuid': Utils.get_unique_identifier(), + 'game': "Factorio" + }]) def on_print(self, args: dict): logger.info(args["text"]) diff --git a/Options.py b/Options.py index ffc3b527..682c44a6 100644 --- a/Options.py +++ b/Options.py @@ -181,6 +181,8 @@ class Choice(Option): return other != self.value elif isinstance(other, bool): return other != bool(self.value) + elif other is None: + return False else: raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}") @@ -217,7 +219,7 @@ class Range(Option, int): return cls.from_text(str(data)) def get_option_name(self, value): - return str(self.value) + return str(value) def __str__(self): return str(self.value) @@ -256,7 +258,7 @@ class OptionDict(Option): raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}") def get_option_name(self, value): - return ", ".join(f"{key}: {value}" for key, value in self.value.items()) + return ", ".join(f"{key}: {v}" for key, v in value.items()) def __contains__(self, item): return item in self.value @@ -282,7 +284,7 @@ class OptionList(Option): return cls.from_text(str(data)) def get_option_name(self, value): - return ", ".join(self.value) + return ", ".join(value) def __contains__(self, item): return item in self.value @@ -310,7 +312,7 @@ class OptionSet(Option): return cls.from_text(str(data)) def get_option_name(self, value): - return ", ".join(self.value) + return ", ".join(value) def __contains__(self, item): return item in self.value