Skip to content

Commit

Permalink
Renames the installation extra https-loader to web-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyfuture committed Jan 4, 2025
1 parent 5e01aa8 commit 6f1a40f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions _delb/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def register_loader(
from typing import Any
from _delb.plugins import plugin_manager
from _delb.plugins.https_loader import https_loader
from _delb.plugins.web_loader import web_loader
from _delb.typing import LoaderResult
Expand All @@ -142,7 +142,7 @@ def ipfs_loader(source: Any, config: SimpleNamespace) -> LoaderResult:
config.source_url = source
config.ipfs_gateway_source_url = IPFS_GATEWAY + source[7:]
return https_loader(config.ipfs_gateway_source_url, config)
return web_loader(config.ipfs_gateway_source_url, config)
# return an indication why this loader didn't attempt to load in order
# to support debugging
Expand All @@ -169,10 +169,10 @@ def ipfs_loader(source: Any, config: SimpleNamespace) -> LoaderResult:
.. testcode::
from _delb.plugins import plugin_manager
from _delb.plugins.https_loader import https_loader
from _delb.plugins.web_loader import web_loader
@plugin_manager.register_loader(before=https_loader)
@plugin_manager.register_loader(before=web_loader)
def mets_loader(source, config) -> LoaderResult:
# loading logic here
pass
Expand Down
12 changes: 6 additions & 6 deletions _delb/plugins/https_loader.py → _delb/plugins/web_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def read(self, size: int = 4096) -> bytes:
return b""

@plugin_manager.register_loader()
def https_loader(
def web_loader(
data: Any, config: SimpleNamespace, client: httpx.Client = DEFAULT_CLIENT
) -> LoaderResult:
"""
Expand All @@ -84,14 +84,14 @@ def https_loader(
import httpx
from _delb.plugins import plugin_manager
from _delb.plugins.https_loader import https_loader
from _delb.plugins.web_loader import web_loader
client = httpx.Client(follow_redirects=False, trust_env=False)
@plugin_manager.register_loader(before=https_loader)
def custom_https_loader(data, config):
return https_loader(data, config, client=client)
@plugin_manager.register_loader(before=web_loader)
def custom_web_loader(data, config):
return web_loader(data, config, client=client)
.. _environment variables: https://www.python-httpx.org/environment_variables/
.. _httpx: https://www.python-httpx.org/
Expand All @@ -104,4 +104,4 @@ def custom_https_loader(data, config):
return result
return "The input value is not an URL with the http or https scheme."

__all__ = (https_loader.__name__,)
__all__ = (web_loader.__name__,)
2 changes: 1 addition & 1 deletion docs/api/documents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Core
Extra
~~~~~

.. automodule:: _delb.plugins.https_loader
.. automodule:: _delb.plugins.web_loader


Parser options
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To install *delb* manually, not as dependency, use pip_::
At the moment there's only one optional dependency to enable document loading
via `http` and `https`, to include it use::

$ pip install delb[https-loader]
$ pip install delb[web-loader]


From source
Expand All @@ -33,7 +33,7 @@ To install it regularly::

Again, to include the loading over *http(s)*::

…/delb-py $ pip install .[https-loader]
…/delb-py $ pip install .[web-loader]

For developing purposes of ``delb`` itself, the library should be installed in
editable_ mode::
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ dependencies = [
]

[project.entry-points.delb]
https-loader = "_delb.plugins.https_loader"
web-loader = "_delb.plugins.web_loader"

[project.optional-dependencies]
https-loader = ["httpx[http2]"]
web-loader = ["httpx[http2]"]

[project.urls]
Changelog = "https://delb.readthedocs.io/latest/changes.html"
Expand Down Expand Up @@ -126,7 +126,7 @@ only-include = [
packages = ["_delb", "delb"]

[tool.hatch.envs.default]
features = ["https-loader"]
features = ["web-loader"]

[tool.hatch.envs.benchmarks]
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_buffer_loader():


@pytest.mark.parametrize("s", ("", "s"))
def test_http_s_loader(httpx_mock, s):
def test_web_loader(httpx_mock, s):
httpx_mock.add_response(
stream=IteratorStream(
(
Expand Down

0 comments on commit 6f1a40f

Please sign in to comment.