Skip to content

Commit

Permalink
refactor!: remove plugin sub-directory and package
Browse files Browse the repository at this point in the history
Now, rather than having to import an api function as `moe.plugins.add.add_item`, it's just `moe.add.add_item`.
  • Loading branch information
jtpavlock committed Dec 20, 2022
1 parent 0ffd10a commit d3d756d
Show file tree
Hide file tree
Showing 71 changed files with 144 additions and 150 deletions.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -22,10 +22,10 @@ Finally, although a lot of Moe's functionality exists around the idea of operati
import argparse
import pathlib
import moe.plugins.musicbrainz as moe_mb
import moe.musicbrainz as moe_mb
from moe.config import Config, ConfigValidationError
from moe.library import Album
from moe.plugins.write import write_tags
from moe.write import write_tags
def main():
Expand Down
42 changes: 21 additions & 21 deletions docs/developers/api/core.rst
Expand Up @@ -44,75 +44,75 @@ Query

Plugins
=======
``moe.plugins``
``moe``

Add
---
``moe.plugins.add``
``moe.add``

.. automodule:: moe.plugins.add
.. automodule:: moe.add
:members:

Duplicate
---------
``moe.plugins.duplicate``
``moe.duplicate``

.. automodule:: moe.plugins.duplicate
.. automodule:: moe.duplicate
:members:

Edit
----
``moe.plugins.edit``
``moe.edit``

.. automodule:: moe.plugins.edit
.. automodule:: moe.edit
:members:

Import
------
``moe.plugins.moe_import``
``moe.moe_import``

.. automodule:: moe.plugins.moe_import
.. automodule:: moe.moe_import
:members:
:exclude-members: match_value_pct

Move
----
``moe.plugins.move``
``moe.move``

.. automodule:: moe.plugins.move
.. automodule:: moe.move
:members:

Musicbrainz
-----------
``moe.plugins.musicbrainz``
``moe.musicbrainz``

.. automodule:: moe.plugins.musicbrainz
.. automodule:: moe.musicbrainz
:members:

Read
----
``moe.plugins.read``
``moe.read``

.. automodule:: moe.plugins.read
.. automodule:: moe.read
:members:

Remove
------
``moe.plugins.remove``
``moe.remove``

.. automodule:: moe.plugins.remove
.. automodule:: moe.remove
:members:

Sync
----
``moe.plugins.sync``
``moe.sync``

.. automodule:: moe.plugins.sync
.. automodule:: moe.sync
:members:

Write
-----
``moe.plugins.write``
``moe.write``

.. automodule:: moe.plugins.write
.. automodule:: moe.write
:members:
2 changes: 1 addition & 1 deletion docs/developers/api/hooks.cli.rst
Expand Up @@ -15,5 +15,5 @@ Plugins

Import
------
.. autoclass:: moe.plugins.moe_import.import_cli.Hooks
.. autoclass:: moe.moe_import.import_cli.Hooks
:members:
8 changes: 4 additions & 4 deletions docs/developers/api/hooks.core.rst
Expand Up @@ -42,20 +42,20 @@ Plugins

Add
---
.. autoclass:: moe.plugins.add.add_core.Hooks
.. autoclass:: moe.add.add_core.Hooks
:members:

Import
------
.. autoclass:: moe.plugins.moe_import.import_core.Hooks
.. autoclass:: moe.moe_import.import_core.Hooks
:members:

Move
----
.. autoclass:: moe.plugins.move.move_core.Hooks
.. autoclass:: moe.move.move_core.Hooks
:members:

Write
-----
.. autoclass:: moe.plugins.write.Hooks
.. autoclass:: moe.write.Hooks
:members:
4 changes: 2 additions & 2 deletions docs/developers/writing_plugins.rst
Expand Up @@ -36,13 +36,13 @@ If you'd like to make your plugin available on pip, there are a few required ste
.. note::
It's encouraged that the actual name of your plugin module or package not include the ``moe_`` prefix. The prefix is only necessary for the name of your project on PyPI.

#. Include the `entry_point group <https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata>`_ ``moe.plugins`` in your ``setup.py`` or ``pyproject.toml``.
#. Include the `entry_point group <https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata>`_ ``moe`` in your ``setup.py`` or ``pyproject.toml``.

* For example, if using *poetry*, include the following in your ``pyproject.toml``.

.. code:: toml
[tool.poetry.plugins."moe.plugins"]
[tool.poetry.plugins."moe"]
"<plugin_name>" = "<plugin_module or package>"
.. seealso::
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/move.rst
Expand Up @@ -45,7 +45,7 @@ Custom Path Template Functions
==============================
Moe allows plugins to create custom path template functions that can be called within the path templates. The function called in the default ``extra_path`` template, ``e_unique``, is an example of a custom path template function. The following custom template functions are included in the move plugin:

.. autofunction:: moe.plugins.move.move_core.e_unique
.. autofunction:: moe.move.move_core.e_unique

.. tip::
- For any path formatting changes, run ``moe move -n`` for a dry-run to avoid any unexpected results.
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions moe/plugins/add/add_cli.py → moe/add/add_cli.py
Expand Up @@ -6,10 +6,10 @@
from typing import Optional, cast

import moe
import moe.add
import moe.cli
from moe.add.add_core import AddError
from moe.library import Album, AlbumError, Extra, Track, TrackError
from moe.plugins import add as moe_add
from moe.plugins.add.add_core import AddError
from moe.util.cli import PromptChoice
from moe.util.cli.query import cli_query

Expand Down Expand Up @@ -110,15 +110,15 @@ def _add_path(path: Path, album: Optional[Album]):
"""
if path.is_file():
try:
moe_add.add_item(Track.from_file(path, album=album))
moe.add.add_item(Track.from_file(path, album=album))
except TrackError:
if not album:
raise AddError(
f"An album query is required to add an extra. [{path=!r}]"
) from None

moe_add.add_item(Extra(album, path))
moe.add.add_item(Extra(album, path))
elif path.is_dir():
moe_add.add_item(Album.from_dir(path))
moe.add.add_item(Album.from_dir(path))
else:
raise AddError(f"Path not found. [{path=}]")
2 changes: 1 addition & 1 deletion moe/plugins/add/add_core.py → moe/add/add_core.py
Expand Up @@ -48,7 +48,7 @@ def pre_add(item: LibItem):
@moe.hookimpl
def add_hooks(pm: pluggy.manager.PluginManager):
"""Registers `add` hookspecs to Moe."""
from moe.plugins.add.add_core import Hooks
from moe.add.add_core import Hooks

pm.add_hookspecs(Hooks)

Expand Down
24 changes: 12 additions & 12 deletions moe/config.py
Expand Up @@ -38,18 +38,18 @@
log = logging.getLogger("moe.config")

DEFAULT_PLUGINS = {
"add": "moe.plugins.add",
"add": "moe.add",
"cli": "moe.cli",
"duplicate": "moe.plugins.duplicate",
"edit": "moe.plugins.edit",
"import": "moe.plugins.moe_import",
"list": "moe.plugins.list",
"move": "moe.plugins.move",
"musicbrainz": "moe.plugins.musicbrainz",
"read": "moe.plugins.read",
"sync": "moe.plugins.sync",
"remove": "moe.plugins.remove",
"write": "moe.plugins.write",
"duplicate": "moe.duplicate",
"edit": "moe.edit",
"import": "moe.moe_import",
"list": "moe.list",
"move": "moe.move",
"musicbrainz": "moe.musicbrainz",
"read": "moe.read",
"sync": "moe.sync",
"remove": "moe.remove",
"write": "moe.write",
}
CORE_PLUGINS = {
"config": "moe.config",
Expand Down Expand Up @@ -99,7 +99,7 @@ def add_hooks(pm: pluggy.manager.PluginManager):
Example:
.. code:: python
from moe.plugins.add import Hooks
from moe.add import Hooks
pm.add_hookspecs(Hooks)
"""

Expand Down
File renamed without changes.
Expand Up @@ -14,7 +14,7 @@
import moe.cli
from moe.cli import console
from moe.library import Album, Extra, LibItem, Track
from moe.plugins.remove import remove_item
from moe.remove import remove_item
from moe.util.cli import PromptChoice, choice_prompt

log = logging.getLogger("moe.cli.dup")
Expand Down
Expand Up @@ -31,7 +31,7 @@ def resolve_dup_items(item_a: LibItem, item_b: LibItem):
1. The field(s) triggering the duplicate detection is altered on one or both
of the items so that they are no longer duplicates.
2. One of the items is removed from the library entirely using
:meth:`~moe.plugins.remove.remove_item`.
:meth:`~moe.remove.remove_item`.
Important:
Duplicates are determined by each item's
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/edit/edit_cli.py → moe/edit/edit_cli.py
Expand Up @@ -5,7 +5,7 @@

import moe
import moe.cli
from moe.plugins import edit
from moe import edit
from moe.util.cli import cli_query, query_parser

log = logging.getLogger("moe.cli.edit")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/library/track.py
Expand Up @@ -89,7 +89,7 @@ def read_custom_tags(
See Also:
* :ref:`Album and track fields <fields:Fields>`
* `Mediafile docs <https://mediafile.readthedocs.io/en/latest/>`_
* The :meth:`~moe.plugins.write.Hooks.write_custom_tags` hook for writing
* The :meth:`~moe.write.Hooks.write_custom_tags` hook for writing
tags.
"""

Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -16,7 +16,7 @@
from moe import config
from moe.cli import console
from moe.library import Album, MetaAlbum, MetaTrack
from moe.plugins.moe_import.import_core import CandidateAlbum
from moe.moe_import.import_core import CandidateAlbum
from moe.util.cli import PromptChoice, choice_prompt
from moe.util.core import get_matching_tracks

Expand Down Expand Up @@ -84,7 +84,7 @@ def add_import_prompt_choice(prompt_choices: list[PromptChoice]):
@moe.hookimpl
def add_hooks(pm: pluggy.manager.PluginManager):
"""Registers `import` cli hookspecs to Moe."""
from moe.plugins.moe_import.import_cli import Hooks
from moe.moe_import.import_cli import Hooks

pm.add_hookspecs(Hooks)

Expand Down
Expand Up @@ -91,7 +91,7 @@ def process_candidates(new_album: Album, candidates: list[CandidateAlbum]):
@moe.hookimpl
def add_hooks(pm: pluggy.manager.PluginManager):
"""Registers `import` core hookspecs to Moe."""
from moe.plugins.moe_import.import_core import Hooks
from moe.moe_import.import_core import Hooks

pm.add_hookspecs(Hooks)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/move/move_cli.py → moe/move/move_cli.py
Expand Up @@ -7,8 +7,8 @@
import sqlalchemy.orm

import moe
from moe import move as moe_move
from moe.library import Album
from moe.plugins import move as moe_move
from moe.util.cli import cli_query

log = logging.getLogger("moe.cli.move")
Expand Down
2 changes: 1 addition & 1 deletion moe/plugins/move/move_core.py → moe/move/move_core.py
Expand Up @@ -40,7 +40,7 @@ def create_path_template_func() -> list[Callable]: # type: ignore
@moe.hookimpl
def add_hooks(pm: pluggy.manager.PluginManager):
"""Registers `add` hookspecs to Moe."""
from moe.plugins.move.move_core import Hooks
from moe.move.move_core import Hooks

pm.add_hookspecs(Hooks)

Expand Down
File renamed without changes.
Expand Up @@ -15,10 +15,10 @@

import moe
import moe.cli
from moe import moe_import
from moe import musicbrainz as moe_mb
from moe.library import Album, Extra, Track
from moe.plugins import moe_import
from moe.plugins import musicbrainz as moe_mb
from moe.plugins.moe_import.import_core import CandidateAlbum
from moe.moe_import.import_core import CandidateAlbum
from moe.util.cli import PromptChoice, cli_query, query_parser

__all__: list[str] = []
Expand Down
Expand Up @@ -27,7 +27,7 @@
import moe
from moe import config
from moe.library import Album, LibItem, MetaAlbum, MetaTrack, Track
from moe.plugins.moe_import.import_core import CandidateAlbum
from moe.moe_import.import_core import CandidateAlbum
from moe.util.core import match

__all__ = [
Expand Down
1 change: 0 additions & 1 deletion moe/plugins/__init__.py

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/read/read_cli.py → moe/read/read_cli.py
Expand Up @@ -5,7 +5,7 @@

import moe
import moe.cli
from moe.plugins import read, remove
from moe import read, remove
from moe.util.cli import cli_query, query_parser

log = logging.getLogger("moe.cli.read")
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/remove/rm_cli.py → moe/remove/rm_cli.py
Expand Up @@ -9,7 +9,7 @@

import moe
import moe.cli
from moe.plugins import remove as moe_rm
from moe import remove as moe_rm
from moe.util.cli import cli_query, query_parser

__all__: list[str] = []
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/sync/sync_cli.py → moe/sync/sync_cli.py
Expand Up @@ -5,7 +5,7 @@

import moe
import moe.cli
from moe.plugins import sync as moe_sync
from moe import sync as moe_sync
from moe.util.cli import cli_query, query_parser

log = logging.getLogger("moe.cli.sync")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion moe/plugins/write.py → moe/write.py
Expand Up @@ -47,7 +47,7 @@ def write_custom_tags(track: Track):
@moe.hookimpl
def add_hooks(pm: pluggy.manager.PluginManager):
"""Registers `write` hookspecs to Moe."""
from moe.plugins.write import Hooks
from moe.write import Hooks

pm.add_hookspecs(Hooks)

Expand Down

0 comments on commit d3d756d

Please sign in to comment.