tlc.core.url_adapter_registry#

A list of registered UrlAdapters

Module Contents#

Classes#

Class

Description

UrlAdapterRegistry

Maintains a list of currently registered UrlAdapters, and provides functionality for de-/serializing objects from Url.

API#

class tlc.core.url_adapter_registry.UrlAdapterRegistry#

Bases: abc.ABC

Maintains a list of currently registered UrlAdapters, and provides functionality for de-/serializing objects from Url.

static register_url_adapter_for_scheme(scheme: tlc.core.url.Scheme, url_adapter: tlc.core.url_adapter.UrlAdapter) None#

Register a URL adapter to be used for the given scheme

static register_url_adapter(url_adapter: tlc.core.url_adapter.UrlAdapter) None#

Register a URL adapter

static get_url_adapter_for_url(url: tlc.core.url.Url, default_value: tlc.core.url_adapter.UrlAdapter | None = None) tlc.core.url_adapter.UrlAdapter | None#

Get the URL adapter for the given URL

static get_url_adapter_for_scheme(scheme: tlc.core.url.Scheme, default_value: tlc.core.url_adapter.UrlAdapter | None = None) tlc.core.url_adapter.UrlAdapter | None#

Get URL adapter for the given scheme

static read_string_content_from_url(url: tlc.core.url.Url, default_value: str | None = None) str#

Resolve UrlAdapter and read the string content from the given URL

If no adapter can be resolved for the given Url return the ‘default_value’ if given else raise an exception

static write_string_content_to_url(url: tlc.core.url.Url, content: str, options: tlc.core.url_adapter.IfExistsOption = IfExistsOption.OVERWRITE) tlc.core.url.Url#

Resolve UrlAdapter and write the string content to the given URL

If no adapter can be resolved for the given Url an exception is raised

static read_binary_content_from_url(url: tlc.core.url.Url, default_value: bytes | None = None) bytes#

Resolve UrlAdapter and read the binary content from the given URL

If no adapter can be resolved for the given Url return the ‘default_value’ if given else raise an exception.

static read_binary_content_from_url_async(url: tlc.core.url.Url, default_value: bytes | None = None) concurrent.futures.Future#

Resolve UrlAdapter and read the binary content from the given URL

If no adapter can be resolved for the given Url return the ‘default_value’ if given else raise an exception.

static write_binary_content_to_url(url: tlc.core.url.Url, content: bytes, options: tlc.core.url_adapter.IfExistsOption = IfExistsOption.OVERWRITE) tlc.core.url.Url#

Resolve UrlAdapter and write the binary content to the given URL

If no adapter can be resolved for the given Url an exception is raised

static write_binary_content_to_url_async(url: tlc.core.url.Url, content: bytes, options: tlc.core.url_adapter.IfExistsOption = IfExistsOption.OVERWRITE) concurrent.futures.Future#

Resolve UrlAdapter and write the binary content to the given URL

If no adapter can be resolved for the given Url an exception is raised

static copy_url(input: tlc.core.url.Url, output: tlc.core.url.Url, options: tlc.core.url_adapter.IfExistsOption = IfExistsOption.OVERWRITE) tlc.core.url.Url#

Resolve UrlAdapter and copy the given URL

If no adapter can be resolved for the given Url an exception is raised

static delete_url(url: tlc.core.url.Url) None#

Resolve UrlAdapter and delete the given URL

If no adapter can be resolved for the given Url an exception is raised

static is_writable(url: tlc.core.url.Url) bool#

Resolve UrlAdapter and check if the given URL is writable

If no adapter can be resolved for the given Url an exception is raised

static make_dirs(url: tlc.core.url.Url, exist_ok: bool = False) None#

Resolve UrlAdapter and create a leaf directory and all intermediate ones at the given URL

If no adapter can be resolved for the given Url an exception is raised

static is_file_hierarchy_flat(url: tlc.core.url.Url) bool#

Resolve UrlAdapter and check if the given URL resides on storage with flat file hierarchy

If no adapter can be resolved for the given Url an exception is raised

static get_file_size(url: tlc.core.url.Url) int#

Resolve UrlAdapter and get the size of the file at the given URL

If no adapter can be resolved for the given Url an exception is raised

static list_dir(url: tlc.core.url.Url) Iterator[tlc.core.url_adapter.UrlAdapterDirEntry]#

Resolve UrlAdapter and list the entries belonging to the directory at the given URL

If no adapter can be resolved for the given Url an exception is raised

static exists(url: tlc.core.url.Url) bool#

Resolve UrlAdapter and check if the given URL exists

If no adapter can be resolved for the given Url an exception is raised

static print_url_adapters(line_prefix: str = '') None#

Print all URL adapters.

static schemes() list[str]#

Get URL schemes for registered adapters

static is_dir(url: tlc.core.url.Url) bool#

Resolve UrlAdapter and check if the given URL is a directory

If no adapter can be resolved for the given Url an exception is raised