tlcurl.url_adapters.gcs_url_adapter

An adapter for resolving reads/writes to URLs starting with gs://

Module Contents

Classes

Class

Description

GSUrlAdapterDirEntry

A directory entry for a GSUrlAdapter

GCSUrlAdapter

An adapter for resolving reads/writes to URLs starting with gs://

API

class tlcurl.url_adapters.gcs_url_adapter.GSUrlAdapterDirEntry(name: str, path: str, is_directory: bool, modified_time: datetime.datetime | None = None)

Bases: tlcurl.url_adapter.UrlAdapterDirEntry

A directory entry for a GSUrlAdapter

property name: str
property path: str
is_dir() bool
is_file() bool
mtime() datetime.datetime
mtime_datetime() datetime.datetime
class tlcurl.url_adapters.gcs_url_adapter.GCSUrlAdapter

Bases: tlcurl.url_adapter.UrlAdapterAsyncFromSync

An adapter for resolving reads/writes to URLs starting with gs://

gs_scheme = None
gs_protocol = None
schemes() list[tlcurl.url.Scheme]
read_string_content_from_url(url: tlcurl.url.Url) str

Read content from URL synchronously

read_binary_content_from_url(url: tlcurl.url.Url) bytes

Read binary content from URL synchronously

delete_url(url: tlcurl.url.Url) None

Delete URL synchronously

make_dirs(url: tlcurl.url.Url, exist_ok: bool = False) None

Create a leaf directory and all intermediate ones synchronously

For GCS, this is a no-op since GCS has a flat namespace. We only create a marker file if the directory doesn’t exist.

get_file_size(url: tlcurl.url.Url) int

Get the size of the file at the given URL synchronously

list_dir(url: tlcurl.url.Url) collections.abc.Iterator[tlcurl.url_adapters.gcs_url_adapter.GSUrlAdapterDirEntry]

List the entries belonging to the directory at the given URL synchronously

exists(url: tlcurl.url.Url) bool

Return True if the given URL refers to an existing path synchronously

is_dir(url: tlcurl.url.Url) bool

Return True if the given URL refers to a directory synchronously

is_writable(url: tlcurl.url.Url) bool

Checks if a Url is writable.

Actual implementation checks if the bucket is writable.

is_file_hierarchy_flat() bool

GCS has a flat file hierarchy

stat(url: tlcurl.url.Url) tlcurl.url_adapters.gcs_url_adapter.GSUrlAdapterDirEntry

Get metadata about a file or directory at the given URL synchronously

touch(url: tlcurl.url.Url) None

Update the last modified timestamp of a file to the current time. Creates the file if it doesn’t exist.

Parameters:

url – The URL of the file to touch

reset_backend() None

Reset the storage client to force recreation on next use