async def _fetch_nothing(self):
line = await self._read_line()
if line is not None:
- raise ProtocolError(f"Got unexpected return value: '{line}'")
+ raise MPDProtocolError(f"Got unexpected return value: '{line}'")
async def _fetch_item(self):
pairs = [_ async for _ in self._read_pairs()]
# SPDX-FileCopyrightText: 2012-2024 kaliko <kaliko@azylum.org>
# SPDX-License-Identifier: LGPL-3.0-or-later
+from .exceptions import MPDCommandError
+
class Range:
def __init__(self, tpl):
try:
return str(int(item))
except (TypeError, ValueError) as err:
- raise CommandError(f'Not an integer: "{item}"') from err
+ raise MPDCommandError(f'Not an integer: "{item}"') from err
return item
def _check(self):
if not isinstance(self.tpl, tuple):
- raise CommandError('Wrong type, provide a tuple')
+ raise MPDCommandError('Wrong type, provide a tuple')
if len(self.tpl) == 0:
return
if len(self.tpl) == 1:
self.lower = self._check_element(self.tpl[0])
return
if len(self.tpl) != 2:
- raise CommandError('Range wrong size (0, 1 or 2 allowed)')
+ raise MPDCommandError('Range wrong size (0, 1 or 2 allowed)')
self.lower = self._check_element(self.tpl[0])
self.upper = self._check_element(self.tpl[1])
if self.lower == '' and self.upper != '':
- raise CommandError(f'Integer expected to start the range: {self.tpl}')
+ raise MPDCommandError(f'Integer expected to start the range: {self.tpl}')
if self.upper.isdigit() and self.lower.isdigit():
if int(self.lower) > int(self.upper):
- raise CommandError(f'Wrong range: {self.lower} > {self.upper}')
+ raise MPDCommandError(f'Wrong range: {self.lower} > {self.upper}')
def escape(text):
return text.replace("\\", "\\\\").replace('"', '\\"')