From 39b38910a6a9f8f99fb57d0986b48afad713e2cd Mon Sep 17 00:00:00 2001 From: Graeme Watt Date: Tue, 14 Nov 2023 12:25:57 +0000 Subject: [PATCH] api/cli: add support for legacy 'yoda1' format * Bump version to 0.2.2. --- README.md | 10 +++++----- hepdata_cli/api.py | 4 ++-- hepdata_cli/cli.py | 2 +- hepdata_cli/version.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e40b9e0..02ae162 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![GitHub Actions Status](https://github.com/HEPData/hepdata-cli/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/HEPData/hepdata-cli/actions?query=branch%3Amaster) -[![Coveralls Status](https://coveralls.io/repos/github/HEPData/hepdata-cli/badge.svg?branch=master)](https://coveralls.io/github/HEPData/hepdata-cli?branch=master) -[![License](https://img.shields.io/github/license/HEPData/hepdata-cli.svg)](https://github.com/HEPData/hepdata-cli/blob/master/LICENSE.txt) +[![GitHub Actions Status](https://github.com/HEPData/hepdata-cli/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/HEPData/hepdata-cli/actions?query=branch%3Amain) +[![Coveralls Status](https://coveralls.io/repos/github/HEPData/hepdata-cli/badge.svg?branch=main)](https://coveralls.io/github/HEPData/hepdata-cli?branch=master) +[![License](https://img.shields.io/github/license/HEPData/hepdata-cli.svg)](https://github.com/HEPData/hepdata-cli/blob/main/LICENSE.txt) [![GitHub Releases](https://img.shields.io/github/release/hepdata/hepdata-cli.svg?maxAge=2592000)](https://github.com/HEPData/hepdata-cli/releases) [![PyPI Version](https://img.shields.io/pypi/v/hepdata-cli)](https://pypi.org/project/hepdata-cli/) [![GitHub Issues](https://img.shields.io/github/issues/hepdata/hepdata-cli.svg?maxAge=2592000)](https://github.com/HEPData/hepdata-cli/issues) @@ -74,11 +74,11 @@ An exact match of the keyword is first attempted, otherwise partial matches are The argument ```[-i/--ids IDTYPE]``` accepts ```IDTYPE``` equal to ```arxiv```, ```hepdata``` or```inspire```. -The argument ```[-f/--file-format FORMAT]``` accepts ```FORMAT``` equal to ```csv```, ```root```, ```yaml```, ```yoda```, or ```json```. +The argument ```[-f/--file-format FORMAT]``` accepts ```FORMAT``` equal to ```csv```, ```root```, ```yaml```, ```yoda```, ```yoda1```, or ```json```. In the first four cases a .tar.gz archive is downloaded and unpacked as a directory, whereas in the last case a .json file is downloaded. The argument ```[-t/--table-name TABLE-NAME]``` accepts a string giving the table name as input. -In this case only the specified table is downloaded as a .csv, .root, .yaml, .yoda or .json file. +In this case only the specified table is downloaded as a .csv, .root, .yaml, .yoda, .yoda1 or .json file. The argument ```[-d/--download-dir DOWNLOAD-DIR]``` specifies the directory to download the files. If not specified, the default download directory is ```./hepdata-downloads```. diff --git a/hepdata_cli/api.py b/hepdata_cli/api.py index 725f73a..e15da06 100644 --- a/hepdata_cli/api.py +++ b/hepdata_cli/api.py @@ -82,7 +82,7 @@ def download(self, id_list, file_format=None, ids=None, table_name='', download_ Downloads from the hepdata database the specified records. :param id_list: list of ids to download. These can be obtained by the find function. - :param file_format: accepts one of ('csv', 'root', 'yaml', 'yoda', 'json'). Specifies the download file format. + :param file_format: accepts one of ('csv', 'root', 'yaml', 'yoda', 'yoda1', 'json'). Specifies the download file format. :param ids: accepts one of ('inspire', 'hepdata'). It specifies what type of ids have been passed. :param table_name: restricts download to specific tables. :param download_dir: defaults to ./hepdata-downloads. Specifies where to download the files. @@ -139,7 +139,7 @@ def _build_urls(self, id_list, file_format, ids, table_name): if type(id_list) not in (tuple, list): id_list = id_list.split() assert len(id_list) > 0, 'Ids are required.' - assert file_format in ['csv', 'root', 'yaml', 'yoda', 'json'], "allowed formats are: csv, root, yaml, yoda and json." + assert file_format in ['csv', 'root', 'yaml', 'yoda', 'yoda1', 'json'], "allowed formats are: csv, root, yaml, yoda, yoda1 and json." assert ids in ['inspire', 'hepdata'], "allowed ids are: inspire and hepdata." if table_name == '': params = {'format': file_format} diff --git a/hepdata_cli/cli.py b/hepdata_cli/cli.py index 1e5a81f..9a9a1ff 100644 --- a/hepdata_cli/cli.py +++ b/hepdata_cli/cli.py @@ -27,7 +27,7 @@ def find(client, query, keyword, ids): @cli.command() @click.argument('id_list', nargs=-1, required=True, type=str) -@click.option('-f', '--file-format', required=True, type=str, help='Specify file format (csv, root, yaml, yoda, or json) to be downloaded.') +@click.option('-f', '--file-format', required=True, type=str, help='Specify file format (csv, root, yaml, yoda, yoda1, or json) to be downloaded.') @click.option('-i', '--ids', required=True, type=str, help='Specify which ids (hepdata or inspire) are given.') @click.option('-t', '--table-name', default='', type=str, help='Specify table to be downloaded.') @click.option('-d', '--download-dir', default='./hepdata-downloads', type=str, help='Specify where to download the files.') diff --git a/hepdata_cli/version.py b/hepdata_cli/version.py index 3ced358..b5fdc75 100644 --- a/hepdata_cli/version.py +++ b/hepdata_cli/version.py @@ -1 +1 @@ -__version__ = "0.2.1" +__version__ = "0.2.2"