From 3067032f1bcec8575cb1f59d1910b62af10dba0e Mon Sep 17 00:00:00 2001 From: alemidev Date: Tue, 10 May 2022 01:30:39 +0200 Subject: [PATCH] use bare SectionProxy, remove UDP bare SectionProxy won't throw KeyError when there's no [Treepuncher] section in config and we're trying to access fields in it: we want default value to be returned so it can fallback accordingly --- src/treepuncher/treepuncher.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index 70a6ee1..0704e4f 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -62,7 +62,7 @@ class Treepuncher( authenticator : AuthInterface def opt(k:str, required=False, default=None) -> Any: - v = kwargs.get(k) or self.config['Treepuncher'].get(k) or default + v = kwargs.get(k) or self.cfg.get(k) or default if not v and required: raise MissingParameterError(f"Missing configuration parameter '{k}'") return v @@ -86,7 +86,6 @@ class Treepuncher( super().__init__( opt('server', required=True), - use_udp=opt('use_udp', default=False), online_mode=online_mode, authenticator=authenticator ) @@ -120,7 +119,7 @@ class Treepuncher( @property def cfg(self) -> SectionProxy: - return self.config["Treepuncher"] + return SectionProxy(self.config, "Treepuncher") @property def playerName(self) -> str: