tlcurl.url_adapters.gcs_url_adapter¶

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

Module Contents¶

Classes¶

Class

Description

GCSUrlAdapter

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

GSUrlAdapterDirEntry

A directory entry for a GSUrlAdapter

API¶

class GCSUrlAdapter¶

Bases: tlcurl.url_adapter.UrlAdapterAsyncFromSync

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

delete_url(
url: Url,
) None¶

Delete URL synchronously

exists(
url: Url,
) bool¶

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

get_file_size(
url: Url,
) int¶

Get the size of the file at the given URL synchronously

gs_protocol = None¶
gs_scheme = None¶
is_dir(
url: Url,
) bool¶

Return True if the given URL refers to a directory synchronously

is_file_hierarchy_flat() bool¶

GCS has a flat file hierarchy

is_writable(
url: Url,
) bool¶

Checks if a Url is writable.

Actual implementation checks if the bucket is writable.

list_dir(
url: Url,
) Iterator[GSUrlAdapterDirEntry]¶

List the entries belonging to the directory at the given 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.

read_binary_content_from_url(
url: Url,
) bytes¶

Read binary content from URL synchronously

read_string_content_from_url(
url: Url,
encoding: str = 'utf-8',
) str¶

Read content from URL synchronously

reset_backend() None¶

Reset the storage client to force recreation on next use

schemes() list[Scheme]¶
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

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

is_dir() bool¶
is_file() bool¶
mtime() datetime¶
mtime_datetime() datetime¶
property name: str¶
property path: str¶