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 GSUrlAdapterDirEntry(
name: str,
path: str,
is_directory: bool,
modified_time: 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
mtime_datetime() datetime
class 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[Scheme]
read_string_content_from_url(
url: Url,
) str

Read content from URL synchronously

read_binary_content_from_url(
url: Url,
) bytes

Read binary content from URL synchronously

delete_url(
url: Url,
) None

Delete URL synchronously

make_dirs(
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: Url,
) int

Get the size of the file at the given URL synchronously

list_dir(
url: Url,
) Iterator[GSUrlAdapterDirEntry]

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

exists(
url: Url,
) bool

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

is_dir(
url: Url,
) bool

Return True if the given URL refers to a directory synchronously

is_writable(
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: Url,
) GSUrlAdapterDirEntry

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

touch(
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