zyra.connectors.backends packageο
HTTP connector backend.
Provides functional helpers to fetch and list resources over HTTP(S), as well
as convenience utilities for GRIB workflows (.idx
parsing and byte-range
downloads) and Content-Length probing.
Functions are intentionally small and dependency-light so they can be used by the CLI, pipelines, or higher-level wrappers without imposing heavy imports.
- zyra.connectors.backends.http.download_byteranges(url: str, byte_ranges: Iterable[str], *, max_workers: int = 10, timeout: int = 60) bytes [source]ο
Download multiple byte ranges and concatenate in the input order.
- zyra.connectors.backends.http.fetch_bytes(url: str, *, timeout: int = 60) bytes [source]ο
Return the raw response body for a GET request.
Parameters - url: HTTP(S) URL to fetch. - timeout: request timeout in seconds.
- zyra.connectors.backends.http.fetch_json(url: str, *, timeout: int = 60)[source]ο
Return the parsed JSON body for a GET request.
- zyra.connectors.backends.http.fetch_text(url: str, *, timeout: int = 60) str [source]ο
Return the response body as text for a GET request.
- zyra.connectors.backends.http.get_idx_lines(url: str, *, timeout: int = 60, max_retries: int = 3) list[str] [source]ο
Fetch and parse the GRIB
.idx
file for a URL.
- zyra.connectors.backends.http.get_size(url: str, *, timeout: int = 60) int | None [source]ο
Return Content-Length for a URL via HTTP HEAD when provided.
- zyra.connectors.backends.http.list_files(url: str, pattern: str | None = None, *, timeout: int = 60) list[str] [source]ο
Best-effort directory listing by scraping anchor tags on index pages.
Returns absolute URLs; optionally filters them via regex
pattern
.
- zyra.connectors.backends.http.post_bytes(url: str, data: bytes, *, timeout: int = 60, content_type: str | None = None) int [source]ο
Backward-compat wrapper for
post_data
.
- zyra.connectors.backends.http.post_data(url: str, data: bytes, *, timeout: int = 60, content_type: str | None = None) int [source]ο
POST raw bytes to a URL and return the HTTP status code.
FTP connector backend.
Thin functional wrappers around the FTPManager to support simple byte fetches
and uploads, directory listing with regex/date filtering, sync-to-local flows,
and advanced GRIB workflows (.idx
handling, ranged downloads).
The URL parser supports anonymous and credentialed forms, e.g.:
ftp://host/path
, ftp://user@host/path
, ftp://user:pass@host/path
.
- class zyra.connectors.backends.ftp.FTPManager[source]ο
Bases:
object
Placeholder for tests to patch.
The backend functions will attempt to delegate to this manager if present. Tests patch this attribute with a mock class exposing expected methods.
- zyra.connectors.backends.ftp.delete(url_or_path: str) bool [source]ο
Delete a remote FTP path (file).
- zyra.connectors.backends.ftp.download_byteranges(url_or_path: str, byte_ranges: Iterable[str], *, max_workers: int = 10, timeout: int = 30) bytes [source]ο
Download multiple ranges via FTP REST and concatenate in the input order.
- zyra.connectors.backends.ftp.exists(url_or_path: str) bool [source]ο
Return True if the remote path exists on the FTP server.
- zyra.connectors.backends.ftp.fetch_bytes(url_or_path: str) bytes [source]ο
Fetch a remote file as bytes from an FTP server.
- zyra.connectors.backends.ftp.get_chunks(url_or_path: str, chunk_size: int = 524288000) list[str] [source]ο
Compute contiguous chunk ranges for an FTP file.
- zyra.connectors.backends.ftp.get_idx_lines(url_or_path: str, *, write_to: str | None = None, timeout: int = 30, max_retries: int = 3) list[str] | None [source]ο
Fetch and parse the GRIB
.idx
for a remote path via FTP.
- zyra.connectors.backends.ftp.get_size(url_or_path: str) int | None [source]ο
Return remote file size in bytes via FTP SIZE.
- zyra.connectors.backends.ftp.list_files(url_or_dir: str, pattern: str | None = None, *, since: str | None = None, until: str | None = None, date_format: str | None = None) list[str] | None [source]ο
List FTP directory contents with optional regex and date filtering.
- zyra.connectors.backends.ftp.parse_ftp_path(url_or_path: str) tuple[str, str, str | None, str | None] [source]ο
Return
(host, remote_path, username, password)
parsed from an FTP path.
- zyra.connectors.backends.ftp.stat(url_or_path: str)[source]ο
Return minimal metadata mapping for a remote path (e.g., size).
- zyra.connectors.backends.ftp.sync_directory(url_or_dir: str, local_dir: str, *, pattern: str | None = None, since: str | None = None, until: str | None = None, date_format: str | None = None, clean_zero_bytes: bool = False) None [source]ο
Sync files from a remote FTP directory to a local directory.
Applies regex/date filters prior to download; optionally removes local zero-byte files before syncing and deletes local files that are no longer present on the server.
- zyra.connectors.backends.ftp.upload_bytes(data: bytes, url_or_path: str) bool [source]ο
Upload bytes to a remote FTP path.
S3 connector backend.
Functional helpers for working with Amazon S3 using the existing S3Manager
implementation under the hood. Exposes byte fetching, uploading, listing, and
introspection utilities, plus GRIB-centric helpers for .idx
and ranged
downloads.
- zyra.connectors.backends.s3.delete(url_or_bucket: str, key: str | None = None) bool [source]ο
Delete an object by URL or bucket+key.
- zyra.connectors.backends.s3.download_byteranges(url_or_bucket: str, key: str | None, byte_ranges: Iterable[str], *, unsigned: bool = False, max_workers: int = 10, timeout: int = 30) bytes [source]ο
Download multiple byte ranges from an S3 object and concatenate in order.
- zyra.connectors.backends.s3.exists(url_or_bucket: str, key: str | None = None) bool [source]ο
Return True if an S3 object exists.
- zyra.connectors.backends.s3.fetch_bytes(url_or_bucket: str, key: str | None = None, *, unsigned: bool = False) bytes [source]ο
Fetch an objectβs full bytes using ranged GET semantics.
Accepts either a single
s3://bucket/key
URL orbucket``+``key
.
- zyra.connectors.backends.s3.get_idx_lines(url_or_bucket: str, key: str | None = None, *, unsigned: bool = False, timeout: int = 30, max_retries: int = 3) list[str] [source]ο
Fetch and parse the GRIB .idx content for an S3 object.
Accepts either a full s3:// URL or (bucket, key).
- zyra.connectors.backends.s3.get_size(url_or_bucket: str, key: str | None = None) int | None [source]ο
Return the size in bytes for an S3 object, or None if unknown.
- zyra.connectors.backends.s3.list_files(prefix_or_url: str | None = None, *, pattern: str | None = None, since: str | None = None, until: str | None = None, date_format: str | None = None) list[str] [source]ο
List S3 keys with optional regex and date filtering.
Accepts either a full
s3://bucket/prefix
orbucket
only (prefix may be None) and filters using regexpattern
and/or filename-based date filtering viasince
/until
withdate_format
.
- zyra.connectors.backends.s3.stat(url_or_bucket: str, key: str | None = None)[source]ο
Return a basic metadata mapping for an object (size/etag/last_modified).
- zyra.connectors.backends.s3.upload_bytes(data: bytes, url_or_bucket: str, key: str | None = None) bool [source]ο
Upload bytes to an S3 object by writing to a temporary file first.
- zyra.connectors.backends.vimeo.update_description(video_uri: str, text: str) str [source]ο
Update the description metadata for a Vimeo video.