WebdavFileSystem#
fsspec compliant webdav file system.
- class webdav4.fsspec.ReopenArgs(file: Type[WebdavFile], fs: WebdavFileSystem, path: str, blocksize: Optional[int], mode: str, size: Optional[int])[source]#
Bases:
NamedTuple
Args to reopen the file.
Create new instance of ReopenArgs(file, fs, path, blocksize, mode, size)
- file: Type[WebdavFile]#
Alias for field number 0
- fs: WebdavFileSystem#
Alias for field number 1
- class webdav4.fsspec.UploadFile(fs: WebdavFileSystem, path: str, mode: str = 'wb', block_size: Optional[int] = None)[source]#
Bases:
SpooledTemporaryFile
UploadFile for Webdav, that uses SpooledTemporaryFile.
In Webdav, you cannot upload in chunks. Similar to http, we need some kind of protocol on top to be able to do that. Sabredav provides a way to upload chunks, but it’s not implemented in Owncloud and Nextcloud. They have a different chunking mechanism. On top of it, there are TUS implementations in newer version of Owncloud.
However, as they are only for chunking, it needs to be seen if it is possible to implement full-breadth of FileObj API through that (I doubt it)
Note that, fsspec’s put_file/pipe_file don’t use this technique and are thus faster as they don’t need buffering. It is recommended to use that if you don’t need to upload content dynamically.
Extended interface with path and fs.
- commit() None [source]#
Commits the file to the given path.
As we cannot upload in chunk, this is where we really upload file.
- readinto(b: Union[bytearray, memoryview, ArrayType[Any], mmap]) int [source]#
Read bytes into the given buffer.
- class webdav4.fsspec.WebdavFile(fs: WebdavFileSystem, path: str, mode: str = 'rb', block_size: Optional[int] = None, autocommit: bool = True, cache_type: str = 'readahead', cache_options: Optional[Dict[str, str]] = None, **kwargs: Any)[source]#
Bases:
AbstractBufferedFile
WebdavFile that provides file-like access to remote file.
Instantiate a file-like object with the provided options.
See fsspec for more information.
- class webdav4.fsspec.WebdavFileSystem(*args, **kwargs)[source]#
Bases:
AbstractFileSystem
Provides access to webdav through fsspec-compliant APIs.
Instantiate WebdavFileSystem with base_url and auth.
- Parameters:
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).
- copy(path1: str, path2: str, recursive: bool = False, on_error: Optional[str] = None, **kwargs: Any) None [source]#
Copy files and directories.
- cp_file(path1: str, path2: str, **kwargs: Any) None [source]#
Copy a file from one path to the other.
- ls(path: str, detail: bool = True, **kwargs: Any) List[Union[str, Dict[str, Any]]] [source]#
ls implementation for fsspec, see fsspec for more information.
- mv(path1: str, path2: str, recursive: bool = False, maxdepth: Optional[bool] = None, **kwargs: Any) None [source]#
Move a file/directory from one path to the other.
- pipe_file(path: str, value: bytes, **kwargs: Any) None [source]#
Upload the contents to given file in the remote webdav server.
- put_file(lpath: PathLike[AnyStr], rpath: str, callback: Optional[Callback] = None, **kwargs: Any) None [source]#
Copy file to remote webdav server.
- put_fileobj(fobj: BinaryIO, rpath: str, callback: Optional[Callback] = None, overwrite: bool = True, size: Optional[int] = None, **kwargs: Any) None #
Upload contents from the fileobj to the remote path.
- rm(path: str, recursive: bool = False, maxdepth: Optional[int] = None) None [source]#
Delete files and directories.
- webdav4.fsspec.reopen(args: ReopenArgs) WebdavFile [source]#
Reopen file when unpickled.