X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=musicpd.py;h=e779355ae24bf9fa00a49729e055e2ba0dee2f3f;hb=c353490d8fac7cb3f17193b1b2e3b9bb191d47ce;hp=61b8b6ffeebc01167d1c47bb83c9c86020b5c3d7;hpb=69bf5d68cc66285f01c7d0ef08cb852d023cf5aa;p=python-musicpd.git diff --git a/musicpd.py b/musicpd.py index 61b8b6f..e779355 100644 --- a/musicpd.py +++ b/musicpd.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2012-2022 kaliko +# SPDX-FileCopyrightText: 2012-2023 kaliko # SPDX-FileCopyrightText: 2021 Wonko der Verständige # SPDX-FileCopyrightText: 2019 Naglis Jonaitis # SPDX-FileCopyrightText: 2019 Bart Van Loon @@ -13,7 +13,7 @@ import os from functools import wraps # Type hint for python <= 3.8 from typing import Any, Dict, List, Tuple -from typing import Literal, Optional, Union +from typing import Optional, Union HELLO_PREFIX = "OK MPD " ERROR_PREFIX = "ACK " @@ -155,6 +155,8 @@ class MPDClient: #: Current connection timeout value, defaults to #: :py:obj:`CONNECTION_TIMEOUT` or env. var. ``MPD_TIMEOUT`` if provided self.mpd_timeout: Union[None,int] = None + #: Protocol version as exposed by the server + self.mpd_version: str = '' self._reset() self._commands = { # Status Commands @@ -416,7 +418,7 @@ class MPDClient: amount -= len(result) return bytes(chunk) - def _read_line(self, binary: Literal[True,False] = False): + def _read_line(self, binary: bool = False): if binary: line = self._rbfile.readline().decode('utf-8') else: @@ -437,7 +439,7 @@ class MPDClient: return None return line - def _read_pair(self, separator: str, binary: Literal[True,False] = False): + def _read_pair(self, separator: str, binary: bool = False): line = self._read_line(binary=binary) if line is None: return None @@ -446,7 +448,7 @@ class MPDClient: raise ProtocolError(f"Could not parse pair: '{line}'") return pair - def _read_pairs(self, separator=": ", binary: Literal[True,False] =False): + def _read_pairs(self, separator=": ", binary: bool =False): pair = self._read_pair(separator, binary=binary) while pair: yield pair @@ -589,7 +591,7 @@ class MPDClient: self.mpd_version = line[len(HELLO_PREFIX):].strip() def _reset(self): - self.mpd_version = None + self.mpd_version = '' self._iterating = False self._pending = [] self._command_list = None