CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-webdavclient

WebDAV client library providing easy access to cloud storage services like Yandex.Drive, Dropbox, Google Drive, Box, and 4shared.

Overview
Eval results
Files

client-operations.mddocs/

Client Operations

Core WebDAV client functionality providing all essential operations for interacting with WebDAV servers. The Client class serves as the primary interface for WebDAV operations, handling connection management, authentication, and basic file operations.

Capabilities

Client Initialization

Creates a WebDAV client with configuration options for server connection, authentication, and proxy settings.

def __init__(self, options: dict) -> None:
    """
    Initialize WebDAV client with configuration options.
    
    Parameters:
    - options: dict containing configuration keys:
        - webdav_hostname: str, WebDAV server URL (required)
        - webdav_login: str, username for authentication
        - webdav_password: str, password for authentication  
        - webdav_token: str, OAuth token for authentication
        - webdav_root: str, root directory path on server
        - cert_path: str, path to SSL certificate file
        - key_path: str, path to SSL private key file
        - recv_speed: int, download speed limit in bytes/second
        - send_speed: int, upload speed limit in bytes/second
        - verbose: bool, enable verbose logging
        - proxy_hostname: str, proxy server URL
        - proxy_login: str, proxy username
        - proxy_password: str, proxy password
    
    Raises:
    - OptionNotValid: if required options are missing or invalid
    """

Connection Validation

Validates client configuration and tests server connectivity.

def valid(self) -> bool:
    """
    Validate client configuration settings.
    
    Returns:
    - bool: True if configuration is valid, False otherwise
    """

Resource Existence Check

Checks whether a remote resource (file or directory) exists on the WebDAV server.

def check(self, remote_path: str = "/") -> bool:
    """
    Check if remote resource exists.
    
    Parameters:
    - remote_path: str, path to remote resource (defaults to root)
    
    Returns:
    - bool: True if resource exists, False otherwise
    
    Raises:
    - NotConnection: if connection to server fails
    """

Resource Information

Retrieves metadata information about a remote resource.

def info(self, remote_path: str = "/") -> dict:
    """
    Get metadata information about remote resource.
    
    Parameters:
    - remote_path: str, path to remote resource
    
    Returns:
    - dict: metadata information including size, modification time, content type
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - NotConnection: if connection to server fails
    """

Directory Listing

Lists contents of a remote directory.

def list(self, remote_path: str = "/") -> list:
    """
    List contents of remote directory.
    
    Parameters:
    - remote_path: str, path to remote directory
    
    Returns:
    - list: list of filenames and directory names in the specified path
    
    Raises:
    - RemoteResourceNotFound: if directory doesn't exist
    - NotConnection: if connection to server fails
    """

Free Space Check

Gets available free space on the WebDAV server.

def free(self) -> int:
    """
    Get available free space on WebDAV server.
    
    Returns:
    - int: available space in bytes
    
    Raises:
    - MethodNotSupported: if server doesn't support free space queries
    - NotConnection: if connection to server fails
    """

Directory Creation

Creates a directory on the remote WebDAV server.

def mkdir(self, remote_path: str) -> None:
    """
    Create directory on remote server.
    
    Parameters:
    - remote_path: str, path where directory should be created
    
    Raises:
    - RemoteParentNotFound: if parent directory doesn't exist
    - NotConnection: if connection to server fails
    - NotEnoughSpace: if insufficient space on server
    """

Resource Deletion

Deletes a file or directory from the remote WebDAV server.

def clean(self, remote_path: str) -> None:
    """
    Delete remote resource (file or directory).
    
    Parameters:
    - remote_path: str, path to resource to delete
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - NotConnection: if connection to server fails
    """

Resource Copy

Copies a file or directory to a new location on the WebDAV server.

def copy(self, remote_path_from: str, remote_path_to: str) -> None:
    """
    Copy remote resource to new location.
    
    Parameters:
    - remote_path_from: str, source path
    - remote_path_to: str, destination path
    
    Raises:
    - RemoteResourceNotFound: if source resource doesn't exist
    - RemoteParentNotFound: if destination parent doesn't exist
    - NotConnection: if connection to server fails
    - NotEnoughSpace: if insufficient space on server
    """

Resource Move

Moves a file or directory to a new location on the WebDAV server.

def move(self, remote_path_from: str, remote_path_to: str) -> None:
    """
    Move remote resource to new location.
    
    Parameters:
    - remote_path_from: str, source path
    - remote_path_to: str, destination path
    
    Raises:
    - RemoteResourceNotFound: if source resource doesn't exist
    - RemoteParentNotFound: if destination parent doesn't exist
    - NotConnection: if connection to server fails
    """

Resource Publishing

Makes a resource publicly accessible and returns a public URL.

def publish(self, remote_path: str) -> str:
    """
    Publish resource and get public URL.
    
    Parameters:
    - remote_path: str, path to resource to publish
    
    Returns:
    - str: public URL for accessing the resource
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - MethodNotSupported: if server doesn't support publishing
    - NotConnection: if connection to server fails
    """

Resource Unpublishing

Removes public access from a previously published resource.

def unpublish(self, remote_path: str) -> None:
    """
    Remove public access from resource.
    
    Parameters:
    - remote_path: str, path to resource to unpublish
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - MethodNotSupported: if server doesn't support unpublishing
    - NotConnection: if connection to server fails
    """

Directory Type Check

Checks whether a remote resource is a directory or file.

def is_dir(self, remote_path: str) -> bool:
    """
    Check if remote resource is a directory.
    
    Parameters:
    - remote_path: str, path to remote resource
    
    Returns:
    - bool: True if resource is directory, False if file
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - MethodNotSupported: if server doesn't support directory type queries
    - NotConnection: if connection to server fails
    """

Resource Object Creation

Creates a Resource object for object-oriented operations on a specific remote path.

def resource(self, remote_path: str) -> Resource:
    """
    Get Resource object for OOP-style operations.
    
    Parameters:
    - remote_path: str, path to remote resource
    
    Returns:
    - Resource: resource object for the specified path
    """

Metadata Operations

Retrieves and sets WebDAV properties on remote resources.

def get_property(self, remote_path: str, option: dict) -> str:
    """
    Get WebDAV property value for remote resource.
    
    Parameters:
    - remote_path: str, path to remote resource
    - option: dict, property specification containing namespace and name
    
    Returns:
    - str: property value
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - NotConnection: if connection to server fails
    """

def set_property(self, remote_path: str, option: dict) -> None:
    """
    Set WebDAV property on remote resource.
    
    Parameters:
    - remote_path: str, path to remote resource  
    - option: dict, property specification with namespace, name, and value
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - MethodNotSupported: if server doesn't support PROPPATCH
    - NotConnection: if connection to server fails
    """

Buffer I/O Operations

Direct buffer-based upload and download operations for memory-efficient file transfers.

def download_to(self, buff, remote_path: str) -> None:
    """
    Download remote resource content to buffer.
    
    Parameters:
    - buff: buffer object to write downloaded data
    - remote_path: str, path to remote resource
    
    Raises:
    - RemoteResourceNotFound: if resource doesn't exist
    - NotConnection: if connection to server fails
    """

def upload_from(self, buff, remote_path: str) -> None:
    """
    Upload buffer content to remote resource.
    
    Parameters:
    - buff: buffer object containing data to upload
    - remote_path: str, path to remote resource
    
    Raises:
    - RemoteParentNotFound: if parent directory doesn't exist
    - NotEnoughSpace: if insufficient space on server
    - NotConnection: if connection to server fails
    """

Usage Examples

Basic Client Setup

import webdav.client as wc

# Basic authentication
options = {
    'webdav_hostname': "https://webdav.server.com",
    'webdav_login': "username",
    'webdav_password': "password"
}
client = wc.Client(options)

# OAuth token authentication
options = {
    'webdav_hostname': "https://webdav.server.com", 
    'webdav_token': "oauth_token_here"
}
client = wc.Client(options)

Directory Operations

# Check if directory exists
if client.check("documents/"):
    # List directory contents
    files = client.list("documents/")
    print(f"Found {len(files)} items")
    
    # Create subdirectory
    client.mkdir("documents/archive/")
    
    # Get directory info
    info = client.info("documents/")
    print(f"Directory size: {info.get('size', 'unknown')}")
    
    # Check if resource is directory
    is_directory = client.is_dir("documents/")
    print(f"Is directory: {is_directory}")

File Operations

# Check file existence and get info
if client.check("data/report.pdf"):
    info = client.info("data/report.pdf")
    print(f"File size: {info['size']} bytes")
    
    # Copy file
    client.copy("data/report.pdf", "backup/report_backup.pdf")
    
    # Move file
    client.move("temp/draft.pdf", "data/final.pdf")
    
    # Publish file for sharing
    public_url = client.publish("data/report.pdf")
    print(f"Public URL: {public_url}")

Install with Tessl CLI

npx tessl i tessl/pypi-webdavclient

docs

client-operations.md

configuration.md

file-transfer.md

index.md

resource-management.md

synchronization.md

tile.json