Skip to content

CLI

ts_bolt.cli¤

download_binary_request(dataset, local_file) ¤

Download remote content in a binary format

Parameters:

Name Type Description Default
dataset RawFileDataset

a RawFileDataset definition

required
local_file Path

where to write the content to

required
Source code in ts_bolt/cli.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def download_binary_request(dataset: RawFileDataset, local_file: Path) -> None:
    """Download remote content in a binary format

    :param dataset: a RawFileDataset definition
    :param local_file: where to write the content to
    """

    r = requests.get(dataset.remote)
    if r.status_code != 200:
        logger.error(f"Can not download {dataset}")
    else:
        with open(local_file, "wb") as f:
            for chunk in r.iter_content(chunk_size=128):
                f.write(chunk)

list(name) ¤

Parameters:

Name Type Description Default
name str

name of datasets to list

required
Source code in ts_bolt/cli.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@bolt.command()
@click.option(
    "--name",
    default=None,
    type=click.Choice(list(dataset_collections.keys())),  # type: ignore[has-type]
    help="name of dataset to be check",
    required=False,
)
def list(name: str) -> None:
    """
    :param name: name of datasets to list
    """
    if name is None:
        click.echo_via_pager("\n".join(f"{d}" for d in dataset_collections))
    else:
        click.secho(f"{name} definition: {dataset_collections[name]}")