retval = self._commands[command]
await self._write_command(command, args)
if callable(retval):
- log.debug('retvat: %s', retval)
return await retval()
return retval
parts.append(f'"{escape(str(arg))}"')
if '\n' in ' '.join(parts):
raise MPDCommandError('new line found in the command!')
- #log.debug(' '.join(parts))
+ log.debug(' '.join(parts))
await self._write_line(' '.join(parts))
def _read_binary(self, amount):
yield value
async def _read_playlist(self):
- for _, value in await self._read_pairs(":"):
+ async for _, value in self._read_pairs(":"):
yield value
async def _read_objects(self, delimiters=None):
if obj:
yield obj
- def _read_command_list(self):
+ async def _read_command_list(self):
try:
for retval in self._command_list:
yield retval()
finally:
self._command_list = None
- self._fetch_nothing()
+ await self._fetch_nothing()
async def _fetch_nothing(self):
line = await self._read_line()
async def _fetch_list(self):
return [_ async for _ in self._read_list()]
- def _fetch_playlist(self):
- return self._read_playlist()
+ async def _fetch_playlist(self):
+ return [_ async for _ in self._read_pairs(':')]
async def _fetch_object(self):
objs = [obj async for obj in self._read_objects()]
async def _fetch_objects(self, delimiters):
return [_ async for _ in self._read_objects(delimiters)]
- def _fetch_changes(self):
- return self._fetch_objects(["cpos"])
+ async def _fetch_changes(self):
+ return await self._fetch_objects(["cpos"])
async def _fetch_songs(self):
return await self._fetch_objects(["file"])
- def _fetch_playlists(self):
- return self._fetch_objects(["playlist"])
+ async def _fetch_playlists(self):
+ return await self._fetch_objects(["playlist"])
- def _fetch_database(self):
- return self._fetch_objects(["file", "directory", "playlist"])
+ async def _fetch_database(self):
+ return await self._fetch_objects(["file", "directory", "playlist"])
- def _fetch_outputs(self):
- return self._fetch_objects(["outputid"])
+ async def _fetch_outputs(self):
+ return await self._fetch_objects(["outputid"])
- def _fetch_plugins(self):
- return self._fetch_objects(["plugin"])
+ async def _fetch_plugins(self):
+ return await self._fetch_objects(["plugin"])
- def _fetch_messages(self):
- return self._fetch_objects(["channel"])
+ async def _fetch_messages(self):
+ return await self._fetch_objects(["channel"])
- def _fetch_mounts(self):
- return self._fetch_objects(["mount"])
+ async def _fetch_mounts(self):
+ return await self._fetch_objects(["mount"])
- def _fetch_neighbors(self):
- return self._fetch_objects(["neighbor"])
+ async def _fetch_neighbors(self):
+ return await self._fetch_objects(["neighbor"])
async def _fetch_composite(self):
obj = {}
await self._read_line(binary=True)
return obj
- def _fetch_command_list(self):
- return self._read_command_list()
+ async def _fetch_command_list(self):
+ return [_ async for _ in self._read_command_list()]