A simple async WebDAV client for Python
Project description
WebDAVit
WebDAVit is a simple async WebDAV client for Python.
Features
- Basic file operations: list, upload, download, mkdir, delete, move, copy, lock.
- Support for authentication.
- Asynchronous operations using
aiohttpfor non-blocking I/O. - Lightweight and easy to use.
Installation
You can install WebDAVit using pip:
pip install webdavit
Or, if you're using uv, you can add it with:
uv add webdavit
Usage
Here's a quick overview of how to use WebDAVit:
import asyncio
import io
from webdavit import WebDAVClient
async def example():
async with WebDAVClient(
'https://webdav.example.com',
username='user',
password='pass',
) as client:
# List files in the root directory
files = await client.list('/')
print(files)
# Upload a file
await client.upload_file('/path/to/local_file.txt', '/remote_file.txt')
await client.upload_text('Hello, WebDAV!', '/hello.txt')
await client.upload_bytes(b'Hello, WebDAV in bytes!', '/hello_bytes.txt')
await client.upload_stream(io.BytesIO(b'Streaming data!'), '/stream.txt')
await client.upload_json({'key': 'value'}, '/data.json')
# Download a file
await client.download_file('/remote_file.txt', '/path/to/local_file.txt')
text = await client.download_text('/hello.txt')
print(text)
jsondata = await client.download_json('/data.json')
print(jsondata)
bytesdata = await client.download_bytes('/hello_bytes.txt')
print(bytesdata)
async with client.download_stream('/stream.txt')
print(await stream.read())
# Delete a file
await client.delete('/remote_file.txt')
# Create a directory
await client.mkdir('/new_directory')
# Delete a directory
# Note that this is a recursive delete
await client.delete('/new_directory')
# Move or rename a file
await client.move('/old_name.txt', '/new_name.txt')
# Copy a file
await client.copy('/source.txt', '/destination.txt')
# Check if a file or directory exists
exists = await client.exists('/some_path')
print(f'Exists: {exists}')
# Get file or directory info
info = await client.get('/some_path')
print(info)
# Lock a file
async with await client.lock('/some_file.txt', timeout=60) as lock:
print(f'Lock info: {lock}')
await client.upload_text(
'Updated content while locked',
'/some_file.txt',
lock_token=lock.token
)
# Refresh the lock if needed
await client.refresh_lock(lock)
print(f'Refreshed lock info: {lock}')
# The lock will be released automatically when exiting the context
asyncio.run(example())
License
WebDAVit is licensed under the MIT License. See the LICENSE.txt file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webdavit-0.1.0.tar.gz.
File metadata
- Download URL: webdavit-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1935881c2db9c4f9a5b4bf8ca5bf123cda01c922be25ac937df34b99ac051d5d
|
|
| MD5 |
9dc8da922a495fa3f4ffd86d70432134
|
|
| BLAKE2b-256 |
83850c05eec49bb20ff9202f54ca5bc2e1f3472d3409a837e176c5c437a94ee9
|
Provenance
The following attestation bundles were made for webdavit-0.1.0.tar.gz:
Publisher:
publish.yml on merlinz01/webdavit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
webdavit-0.1.0.tar.gz -
Subject digest:
1935881c2db9c4f9a5b4bf8ca5bf123cda01c922be25ac937df34b99ac051d5d - Sigstore transparency entry: 458169795
- Sigstore integration time:
-
Permalink:
merlinz01/webdavit@09fe45c0d3e8e3b9fead5c6a0fed820448fae229 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/merlinz01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@09fe45c0d3e8e3b9fead5c6a0fed820448fae229 -
Trigger Event:
push
-
Statement type:
File details
Details for the file webdavit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: webdavit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de5d929f436d674df99b9d74743c144b5c88e731df9b52032eff433c9bc7048a
|
|
| MD5 |
e7ca601d167699ec2f27b78344ca02b0
|
|
| BLAKE2b-256 |
ffe65d02592d8b594655dc30d546950b1811b62a48748dbb2454552895c6eb70
|
Provenance
The following attestation bundles were made for webdavit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on merlinz01/webdavit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
webdavit-0.1.0-py3-none-any.whl -
Subject digest:
de5d929f436d674df99b9d74743c144b5c88e731df9b52032eff433c9bc7048a - Sigstore transparency entry: 458169801
- Sigstore integration time:
-
Permalink:
merlinz01/webdavit@09fe45c0d3e8e3b9fead5c6a0fed820448fae229 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/merlinz01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@09fe45c0d3e8e3b9fead5c6a0fed820448fae229 -
Trigger Event:
push
-
Statement type: