Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow only use client without base_url #187

Open
z0z0r4 opened this issue Jul 29, 2024 · 1 comment
Open

Allow only use client without base_url #187

z0z0r4 opened this issue Jul 29, 2024 · 1 comment

Comments

@z0z0r4
Copy link

z0z0r4 commented Jul 29, 2024

from webdav4.fsspec import WebdavFileSystem
from webdav4.client import Client

client = Client("http://localhost:5244/dav", auth=("admin", "admin"))

fs = WebdavFileSystem(client=client)

like this which raised

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/fsspec/spec.py", line 81, in __call__
    obj = super().__call__(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: WebdavFileSystem.__init__() missing 1 required positional argument: 'base_url'

Change:

class WebdavFileSystem(AbstractFileSystem):
    """Provides access to webdav through fsspec-compliant APIs."""

    protocol = ("webdav", "dav")

    def __init__(
        self,
        base_url: Optional["URLTypes"] = None,
        auth: Optional["AuthTypes"] = None,
        client: Optional["Client"] = None,
        **client_opts: Any,
    ) -> None:
        """Instantiate WebdavFileSystem with base_url and auth.

        Args:
            base_url: base url of the server
            auth: Authentication to the server
                Refer to HTTPX's auth for more information.
            client: Webdav client to use instead, useful for testing/mocking,
                or extending WebdavFileSystem.
            client_opts: Extra args that are passed to Webdav Client.
                (refer to it's documenting for more information).
        """
        super().__init__()
        client_opts.setdefault("chunk_size", self.blocksize)
        if not base_url and not client:
            raise ValueError("Either base_url or client must be provided")
        self.client = client or Client(base_url, auth=auth, **client_opts)
@z0z0r4
Copy link
Author

z0z0r4 commented Jul 29, 2024

Should I open a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant