Skip to content

Commit

Permalink
Merge pull request #2504 from sopel-irc/modules-builtins
Browse files Browse the repository at this point in the history
modules: rename built-in plugins to "builtins"
  • Loading branch information
dgw authored Oct 31, 2023
2 parents eb5e029 + d4a0efd commit 26d57fa
Show file tree
Hide file tree
Showing 57 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/source/plugin/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ from other plugins, including commands. For example, this can be used to add
an alias for an existing command::

from sopel import plugin
from sopel.modules import wikipedia as wp
from sopel.builtins import wikipedia as wp

@plugin.command("wiki")
@plugin.output_prefix(wp.wikipedia.output_prefix)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sopel/modules/url.py → sopel/builtins/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def check_callbacks(bot: SopelWrapper, url: str, use_excludes: bool = True) -> b
.. seealso::
The :func:`~sopel.modules.url.setup` function that defines the
The :func:`~sopel.builtins.url.setup` function that defines the
``url_exclude`` in ``bot.memory``.
.. versionchanged:: 7.0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sopel/modules/xkcd.py → sopel/builtins/xkcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import requests

from sopel import plugin
from sopel.modules.search import duck_search
from sopel.builtins.search import duck_search

LOGGER = logging.getLogger(__name__)
PLUGIN_OUTPUT_PREFIX = '[xkcd] '
Expand Down
16 changes: 8 additions & 8 deletions sopel/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* homedir's ``plugins`` directory
* ``sopel.plugins`` entry point group
* ``sopel_modules``'s subpackages
* ``sopel.modules``'s core plugins
* ``sopel.builtins``'s core plugins
(The ``coretasks`` plugin is *always* the one from ``sopel.coretasks`` and
cannot be overridden.)
Expand Down Expand Up @@ -62,21 +62,21 @@ def find_internal_plugins():
"""List internal plugins.
:return: yield instances of :class:`~.handlers.PyModulePlugin`
configured for ``sopel.modules.*``
configured for ``sopel.builtins.*``
Internal plugins can be found under ``sopel.modules``. This list does not
Internal plugins can be found under ``sopel.builtins``. This list does not
include the ``coretasks`` plugin.
"""
modules = importlib.util.find_spec('sopel.modules')
if modules is None or modules.submodule_search_locations is None:
builtins = importlib.util.find_spec('sopel.builtins')
if builtins is None or builtins.submodule_search_locations is None:
raise RuntimeError('Cannot resolve internal plugins')
plugin_list = itertools.chain.from_iterable(
_list_plugin_filenames(path)
for path in modules.submodule_search_locations
for path in builtins.submodule_search_locations
)

for name, _ in set(plugin_list):
yield handlers.PyModulePlugin(name, 'sopel.modules')
yield handlers.PyModulePlugin(name, 'sopel.builtins')


def find_sopel_modules_plugins():
Expand Down Expand Up @@ -210,7 +210,7 @@ def get_usable_plugins(settings):
* homedir's ``plugins`` directory
* ``sopel.plugins`` entry point group
* ``sopel_modules``'s subpackages
* ``sopel.modules``'s core plugins
* ``sopel.builtins``'s core plugins
(The ``coretasks`` plugin is *always* the one from ``sopel.coretasks`` and
cannot be overridden.)
Expand Down
10 changes: 5 additions & 5 deletions sopel/plugins/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class AbstractPluginHandler(abc.ABC):
configure, load, shutdown, etc. a Sopel plugin (or "module").
It is through this interface that Sopel will interact with its plugins,
whether internal (from ``sopel.modules``) or external (from the Python
whether internal (from ``sopel.builtins``) or external (from the Python
files in a directory, to ``sopel_modules.*`` subpackages).
Sopel's loader will create a "Plugin Handler" for each plugin it finds, to
Expand Down Expand Up @@ -236,18 +236,18 @@ class PyModulePlugin(AbstractPluginHandler):
>>> import sys
>>> from sopel.plugins.handlers import PyModulePlugin
>>> plugin = PyModulePlugin('xkcd', 'sopel.modules')
>>> plugin = PyModulePlugin('xkcd', 'sopel.builtins')
>>> plugin.module_name
'sopel.modules.xkcd'
'sopel.builtins.xkcd'
>>> plugin.load()
>>> plugin.module_name in sys.modules
True
Is the same as this::
>>> import sys
>>> from sopel.modules import xkcd
>>> 'sopel.modules.xkcd' in sys.modules
>>> from sopel.builtins import xkcd
>>> 'sopel.builtins.xkcd' in sys.modules
True
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from sopel.modules import adminchannel
from sopel.builtins import adminchannel


VALID_INPUTS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for Sopel's ``announce`` plugin"""
from __future__ import annotations

from sopel.modules import announce
from sopel.builtins import announce


def test_chunks():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from sopel import formatting
from sopel.modules import choose
from sopel.builtins import choose


UNICODE_ZS_CATEGORY = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import requests.exceptions

from sopel.modules import find_updates
from sopel.builtins import find_updates


TMP_CONFIG = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import requests.exceptions

from sopel.modules import isup
from sopel.builtins import isup
from sopel.tests import rawlist


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from sopel import formatting
from sopel.modules import tell
from sopel.builtins import tell


def test_load_reminders_empty(tmpdir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from sopel import bot, loader, plugin, plugins, trigger
from sopel.modules import url
from sopel.builtins import url


TMP_CONFIG = """
Expand All @@ -27,7 +27,7 @@
@pytest.fixture
def mockbot(configfactory):
tmpconfig = configfactory('test.cfg', TMP_CONFIG)
url_plugin = plugins.handlers.PyModulePlugin('url', 'sopel.modules')
url_plugin = plugins.handlers.PyModulePlugin('url', 'sopel.builtins')

# setup the bot
sopel = bot.Sopel(tmpconfig)
Expand Down
2 changes: 1 addition & 1 deletion test/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def test_register_unregister_plugin(tmpconfig, mockplugin):
def test_remove_plugin_unknown_plugin(tmpconfig):
sopel = bot.Sopel(tmpconfig, daemon=False)

handler = plugins.handlers.PyModulePlugin('admin', 'sopel.modules')
handler = plugins.handlers.PyModulePlugin('admin', 'sopel.builtins')
with pytest.raises(plugins.exceptions.PluginNotRegistered):
sopel.remove_plugin(handler, [], [], [], [])

Expand Down

0 comments on commit 26d57fa

Please sign in to comment.