From 264b72f0799788e4284d1cfbef569f04fcbe54ce Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 23 Feb 2024 14:26:12 +0100 Subject: [PATCH 1/3] Change project layout --- .gitignore | 15 +++++++-------- pyproject.toml | 2 +- {mopidy_mpd => src/mopidy_mpd}/__init__.py | 0 {mopidy_mpd => src/mopidy_mpd}/actor.py | 0 {mopidy_mpd => src/mopidy_mpd}/dispatcher.py | 0 {mopidy_mpd => src/mopidy_mpd}/exceptions.py | 0 {mopidy_mpd => src/mopidy_mpd}/ext.conf | 0 {mopidy_mpd => src/mopidy_mpd}/formatting.py | 0 {mopidy_mpd => src/mopidy_mpd}/network.py | 0 .../mopidy_mpd}/protocol/__init__.py | 0 .../mopidy_mpd}/protocol/audio_output.py | 0 .../mopidy_mpd}/protocol/channels.py | 0 .../mopidy_mpd}/protocol/command_list.py | 0 .../mopidy_mpd}/protocol/connection.py | 0 .../mopidy_mpd}/protocol/current_playlist.py | 0 {mopidy_mpd => src/mopidy_mpd}/protocol/mount.py | 0 .../mopidy_mpd}/protocol/music_db.py | 0 .../mopidy_mpd}/protocol/playback.py | 0 .../mopidy_mpd}/protocol/reflection.py | 0 {mopidy_mpd => src/mopidy_mpd}/protocol/status.py | 0 .../mopidy_mpd}/protocol/stickers.py | 0 .../mopidy_mpd}/protocol/stored_playlists.py | 0 .../mopidy_mpd}/protocol/tagtype_list.py | 0 {mopidy_mpd => src/mopidy_mpd}/session.py | 0 {mopidy_mpd => src/mopidy_mpd}/tokenize.py | 0 {mopidy_mpd => src/mopidy_mpd}/translator.py | 0 {mopidy_mpd => src/mopidy_mpd}/uri_mapper.py | 0 tests/network/test_connection.py | 2 +- tests/network/test_lineprotocol.py | 1 + tests/network/test_server.py | 2 +- tests/protocol/__init__.py | 2 +- tests/protocol/test_connection.py | 1 + tests/protocol/test_idle.py | 1 + tests/protocol/test_music_db.py | 2 +- tests/protocol/test_regression.py | 2 +- tests/protocol/test_stored_playlists.py | 2 +- tests/test_actor.py | 1 - tests/test_dispatcher.py | 2 +- tests/test_exceptions.py | 1 - tests/test_status.py | 2 +- tests/test_translator.py | 2 +- 41 files changed, 20 insertions(+), 20 deletions(-) rename {mopidy_mpd => src/mopidy_mpd}/__init__.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/actor.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/dispatcher.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/exceptions.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/ext.conf (100%) rename {mopidy_mpd => src/mopidy_mpd}/formatting.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/network.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/__init__.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/audio_output.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/channels.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/command_list.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/connection.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/current_playlist.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/mount.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/music_db.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/playback.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/reflection.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/status.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/stickers.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/stored_playlists.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/protocol/tagtype_list.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/session.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/tokenize.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/translator.py (100%) rename {mopidy_mpd => src/mopidy_mpd}/uri_mapper.py (100%) diff --git a/.gitignore b/.gitignore index 03640c9..dadde9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ +*.egg-info *.pyc -/.coverage -/.mypy_cache/ -/.pytest_cache/ -/.tox/ -/*.egg-info -/build/ -/dist/ -/MANIFEST +.coverage +.mypy_cache/ +.pytest_cache/ +.tox/ +build/ +dist/ diff --git a/pyproject.toml b/pyproject.toml index 676792f..32d30a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ ignore = [ ] [tool.ruff.lint.per-file-ignores] -"mopidy_mpd/protocol/*" = [ +"src/mopidy_mpd/protocol/*" = [ "ARG001", # unused-function-argument ] "tests/*" = [ diff --git a/mopidy_mpd/__init__.py b/src/mopidy_mpd/__init__.py similarity index 100% rename from mopidy_mpd/__init__.py rename to src/mopidy_mpd/__init__.py diff --git a/mopidy_mpd/actor.py b/src/mopidy_mpd/actor.py similarity index 100% rename from mopidy_mpd/actor.py rename to src/mopidy_mpd/actor.py diff --git a/mopidy_mpd/dispatcher.py b/src/mopidy_mpd/dispatcher.py similarity index 100% rename from mopidy_mpd/dispatcher.py rename to src/mopidy_mpd/dispatcher.py diff --git a/mopidy_mpd/exceptions.py b/src/mopidy_mpd/exceptions.py similarity index 100% rename from mopidy_mpd/exceptions.py rename to src/mopidy_mpd/exceptions.py diff --git a/mopidy_mpd/ext.conf b/src/mopidy_mpd/ext.conf similarity index 100% rename from mopidy_mpd/ext.conf rename to src/mopidy_mpd/ext.conf diff --git a/mopidy_mpd/formatting.py b/src/mopidy_mpd/formatting.py similarity index 100% rename from mopidy_mpd/formatting.py rename to src/mopidy_mpd/formatting.py diff --git a/mopidy_mpd/network.py b/src/mopidy_mpd/network.py similarity index 100% rename from mopidy_mpd/network.py rename to src/mopidy_mpd/network.py diff --git a/mopidy_mpd/protocol/__init__.py b/src/mopidy_mpd/protocol/__init__.py similarity index 100% rename from mopidy_mpd/protocol/__init__.py rename to src/mopidy_mpd/protocol/__init__.py diff --git a/mopidy_mpd/protocol/audio_output.py b/src/mopidy_mpd/protocol/audio_output.py similarity index 100% rename from mopidy_mpd/protocol/audio_output.py rename to src/mopidy_mpd/protocol/audio_output.py diff --git a/mopidy_mpd/protocol/channels.py b/src/mopidy_mpd/protocol/channels.py similarity index 100% rename from mopidy_mpd/protocol/channels.py rename to src/mopidy_mpd/protocol/channels.py diff --git a/mopidy_mpd/protocol/command_list.py b/src/mopidy_mpd/protocol/command_list.py similarity index 100% rename from mopidy_mpd/protocol/command_list.py rename to src/mopidy_mpd/protocol/command_list.py diff --git a/mopidy_mpd/protocol/connection.py b/src/mopidy_mpd/protocol/connection.py similarity index 100% rename from mopidy_mpd/protocol/connection.py rename to src/mopidy_mpd/protocol/connection.py diff --git a/mopidy_mpd/protocol/current_playlist.py b/src/mopidy_mpd/protocol/current_playlist.py similarity index 100% rename from mopidy_mpd/protocol/current_playlist.py rename to src/mopidy_mpd/protocol/current_playlist.py diff --git a/mopidy_mpd/protocol/mount.py b/src/mopidy_mpd/protocol/mount.py similarity index 100% rename from mopidy_mpd/protocol/mount.py rename to src/mopidy_mpd/protocol/mount.py diff --git a/mopidy_mpd/protocol/music_db.py b/src/mopidy_mpd/protocol/music_db.py similarity index 100% rename from mopidy_mpd/protocol/music_db.py rename to src/mopidy_mpd/protocol/music_db.py diff --git a/mopidy_mpd/protocol/playback.py b/src/mopidy_mpd/protocol/playback.py similarity index 100% rename from mopidy_mpd/protocol/playback.py rename to src/mopidy_mpd/protocol/playback.py diff --git a/mopidy_mpd/protocol/reflection.py b/src/mopidy_mpd/protocol/reflection.py similarity index 100% rename from mopidy_mpd/protocol/reflection.py rename to src/mopidy_mpd/protocol/reflection.py diff --git a/mopidy_mpd/protocol/status.py b/src/mopidy_mpd/protocol/status.py similarity index 100% rename from mopidy_mpd/protocol/status.py rename to src/mopidy_mpd/protocol/status.py diff --git a/mopidy_mpd/protocol/stickers.py b/src/mopidy_mpd/protocol/stickers.py similarity index 100% rename from mopidy_mpd/protocol/stickers.py rename to src/mopidy_mpd/protocol/stickers.py diff --git a/mopidy_mpd/protocol/stored_playlists.py b/src/mopidy_mpd/protocol/stored_playlists.py similarity index 100% rename from mopidy_mpd/protocol/stored_playlists.py rename to src/mopidy_mpd/protocol/stored_playlists.py diff --git a/mopidy_mpd/protocol/tagtype_list.py b/src/mopidy_mpd/protocol/tagtype_list.py similarity index 100% rename from mopidy_mpd/protocol/tagtype_list.py rename to src/mopidy_mpd/protocol/tagtype_list.py diff --git a/mopidy_mpd/session.py b/src/mopidy_mpd/session.py similarity index 100% rename from mopidy_mpd/session.py rename to src/mopidy_mpd/session.py diff --git a/mopidy_mpd/tokenize.py b/src/mopidy_mpd/tokenize.py similarity index 100% rename from mopidy_mpd/tokenize.py rename to src/mopidy_mpd/tokenize.py diff --git a/mopidy_mpd/translator.py b/src/mopidy_mpd/translator.py similarity index 100% rename from mopidy_mpd/translator.py rename to src/mopidy_mpd/translator.py diff --git a/mopidy_mpd/uri_mapper.py b/src/mopidy_mpd/uri_mapper.py similarity index 100% rename from mopidy_mpd/uri_mapper.py rename to src/mopidy_mpd/uri_mapper.py diff --git a/tests/network/test_connection.py b/tests/network/test_connection.py index 5903a8d..1c6cb1d 100644 --- a/tests/network/test_connection.py +++ b/tests/network/test_connection.py @@ -6,8 +6,8 @@ import pykka from gi.repository import GLib - from mopidy_mpd import network + from tests import any_int, any_unicode diff --git a/tests/network/test_lineprotocol.py b/tests/network/test_lineprotocol.py index 9ee7ab1..eb87d2c 100644 --- a/tests/network/test_lineprotocol.py +++ b/tests/network/test_lineprotocol.py @@ -3,6 +3,7 @@ from unittest.mock import Mock, sentinel from mopidy_mpd import network + from tests import any_unicode diff --git a/tests/network/test_server.py b/tests/network/test_server.py index c1fda3d..5f90365 100644 --- a/tests/network/test_server.py +++ b/tests/network/test_server.py @@ -5,8 +5,8 @@ from unittest.mock import Mock, patch, sentinel from gi.repository import GLib - from mopidy_mpd import network + from tests import any_int diff --git a/tests/protocol/__init__.py b/tests/protocol/__init__.py index 793d8ec..de63994 100644 --- a/tests/protocol/__init__.py +++ b/tests/protocol/__init__.py @@ -3,8 +3,8 @@ import pykka from mopidy import core - from mopidy_mpd import session, uri_mapper + from tests import dummy_audio, dummy_backend, dummy_mixer diff --git a/tests/protocol/test_connection.py b/tests/protocol/test_connection.py index a418ff9..df742e7 100644 --- a/tests/protocol/test_connection.py +++ b/tests/protocol/test_connection.py @@ -1,6 +1,7 @@ from unittest.mock import patch from mopidy_mpd.protocol import tagtype_list + from tests import protocol diff --git a/tests/protocol/test_idle.py b/tests/protocol/test_idle.py index efbaeb9..89d7a0a 100644 --- a/tests/protocol/test_idle.py +++ b/tests/protocol/test_idle.py @@ -1,6 +1,7 @@ from unittest.mock import patch from mopidy_mpd.protocol.status import SUBSYSTEMS + from tests import protocol diff --git a/tests/protocol/test_music_db.py b/tests/protocol/test_music_db.py index 169cd06..b8ef56b 100644 --- a/tests/protocol/test_music_db.py +++ b/tests/protocol/test_music_db.py @@ -2,8 +2,8 @@ from unittest import mock from mopidy.models import Album, Artist, Playlist, Ref, SearchResult, Track - from mopidy_mpd.protocol import music_db, stored_playlists + from tests import protocol # TODO: split into more modules for faster parallel tests? diff --git a/tests/protocol/test_regression.py b/tests/protocol/test_regression.py index 7f7d319..e9c6c53 100644 --- a/tests/protocol/test_regression.py +++ b/tests/protocol/test_regression.py @@ -2,8 +2,8 @@ from unittest import mock from mopidy.models import Playlist, Ref, Track - from mopidy_mpd.protocol import stored_playlists + from tests import protocol diff --git a/tests/protocol/test_stored_playlists.py b/tests/protocol/test_stored_playlists.py index 75d04eb..8eb96e6 100644 --- a/tests/protocol/test_stored_playlists.py +++ b/tests/protocol/test_stored_playlists.py @@ -1,8 +1,8 @@ from unittest import mock from mopidy.models import Playlist, Track - from mopidy_mpd.protocol import stored_playlists + from tests import protocol diff --git a/tests/test_actor.py b/tests/test_actor.py index c76dde8..cb8b563 100644 --- a/tests/test_actor.py +++ b/tests/test_actor.py @@ -1,7 +1,6 @@ from unittest import mock import pytest - from mopidy_mpd import actor # NOTE: Should be kept in sync with all events from mopidy.core.listener diff --git a/tests/test_dispatcher.py b/tests/test_dispatcher.py index 5496093..1145601 100644 --- a/tests/test_dispatcher.py +++ b/tests/test_dispatcher.py @@ -4,10 +4,10 @@ import pytest from mopidy import core from mopidy.models import Ref - from mopidy_mpd.dispatcher import MpdContext, MpdDispatcher from mopidy_mpd.exceptions import MpdAckError from mopidy_mpd.uri_mapper import MpdUriMapper + from tests import dummy_backend diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index a7b3dae..97c49c8 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -1,7 +1,6 @@ import unittest import pytest - from mopidy_mpd.exceptions import ( MpdAckError, MpdNoCommandError, diff --git a/tests/test_status.py b/tests/test_status.py index 428f340..962b6b4 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -4,9 +4,9 @@ from mopidy import core from mopidy.core import PlaybackState from mopidy.models import Track - from mopidy_mpd import dispatcher from mopidy_mpd.protocol import status + from tests import dummy_audio, dummy_backend, dummy_mixer PAUSED = PlaybackState.PAUSED diff --git a/tests/test_translator.py b/tests/test_translator.py index b88686e..fd99a21 100644 --- a/tests/test_translator.py +++ b/tests/test_translator.py @@ -1,9 +1,9 @@ import unittest from mopidy.models import Album, Artist, Playlist, TlTrack, Track - from mopidy_mpd import translator from mopidy_mpd.protocol import tagtype_list + from tests import path_utils From 7b65a61dfad656e4e5f2c33e68f6e85c8ab5436f Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 23 Feb 2024 14:27:42 +0100 Subject: [PATCH 2/3] Replace pkg_resources with importlib.metadata --- src/mopidy_mpd/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mopidy_mpd/__init__.py b/src/mopidy_mpd/__init__.py index df05d23..6647f15 100644 --- a/src/mopidy_mpd/__init__.py +++ b/src/mopidy_mpd/__init__.py @@ -1,9 +1,9 @@ import pathlib +from importlib.metadata import version -import pkg_resources from mopidy import config, ext -__version__ = pkg_resources.get_distribution("Mopidy-MPD").version +__version__ = version("Mopidy-MPD") class Extension(ext.Extension): From 3f39c7418ecf35d5b2d107abf9814c3fde4d1ae2 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 23 Feb 2024 14:33:32 +0100 Subject: [PATCH 3/3] Avoid using deprecated core.playback.play(TlTrack) --- src/mopidy_mpd/protocol/playback.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mopidy_mpd/protocol/playback.py b/src/mopidy_mpd/protocol/playback.py index dc3e4dc..98676c6 100644 --- a/src/mopidy_mpd/protocol/playback.py +++ b/src/mopidy_mpd/protocol/playback.py @@ -177,7 +177,7 @@ def play(context, songpos=None): try: tl_track = context.core.tracklist.slice(songpos, songpos + 1).get()[0] - return context.core.playback.play(tl_track).get() + return context.core.playback.play(tlid=tl_track.tlid).get() except IndexError as exc: raise exceptions.MpdArgError("Bad song index") from exc @@ -191,11 +191,11 @@ def _play_minus_one(context): current_tl_track = context.core.playback.get_current_tl_track().get() if current_tl_track is not None: - return context.core.playback.play(current_tl_track).get() + return context.core.playback.play(tlid=current_tl_track.tlid).get() tl_tracks = context.core.tracklist.slice(0, 1).get() if tl_tracks: - return context.core.playback.play(tl_tracks[0]).get() + return context.core.playback.play(tlid=tl_tracks[0].tlid).get() return None # Fail silently @@ -223,7 +223,7 @@ def playid(context, tlid): tl_tracks = context.core.tracklist.filter({"tlid": [tlid]}).get() if not tl_tracks: raise exceptions.MpdNoExistError("No such song") - return context.core.playback.play(tl_tracks[0]).get() + return context.core.playback.play(tlid=tl_tracks[0].tlid).get() @protocol.commands.add("previous")