From 48e90c82fba8cdd41bf5dd1e1ea804f27d4712f5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 18:18:10 +0000 Subject: [PATCH] alter format of __repr__ in Req + Event clients password now defaults to empty string, not None. --- README.md | 2 +- obsws_python/baseclient.py | 4 ++-- obsws_python/events.py | 6 ++++-- obsws_python/reqs.py | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9528a27..b1d2a44 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ By default the clients connect with parameters: - `host`: "localhost" - `port`: 4455 -- `password`: None +- `password`: "" You may override these parameters by storing them in a toml config file or passing them as keyword arguments. diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 273e96b..e1dfc52 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -14,7 +14,7 @@ class ObsClient: logger = logging.getLogger("baseclient.obsclient") def __init__(self, **kwargs): - defaultkwargs = {"host": "localhost", "port": 4455, "password": None, "subs": 0} + defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0} if not any(key in kwargs for key in ("host", "port", "password")): kwargs |= self._conn_from_toml() kwargs = defaultkwargs | kwargs @@ -22,7 +22,7 @@ class ObsClient: setattr(self, attr, val) self.logger.info( - "Connecting with parameters: {host} {port} {password} {subs}".format( + "Connecting with parameters: host='{host}' port={port} password='{password}' subs={subs}".format( **self.__dict__ ) ) diff --git a/obsws_python/events.py b/obsws_python/events.py index f281340..9a942e6 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -28,8 +28,10 @@ class EventClient: self.subscribe() def __repr__(self): - return type(self).__name__ + "({host} {port} {password} {subs})".format( - **self.base_client.__dict__ + return type( + self + ).__name__ + "(host='{host}', port={port}, password='{password}', subs={subs})".format( + **self.base_client.__dict__, ) def __str__(self): diff --git a/obsws_python/reqs.py b/obsws_python/reqs.py index 4771092..f823431 100644 --- a/obsws_python/reqs.py +++ b/obsws_python/reqs.py @@ -26,8 +26,10 @@ class ReqClient: self.base_client.ws.close() def __repr__(self): - return type(self).__name__ + "({host} {port} {password})".format( - **self.base_client.__dict__ + return type( + self + ).__name__ + "(host='{host}', port={port}, password='{password}')".format( + **self.base_client.__dict__, ) def __str__(self):