Skip to content

Commit

Permalink
api/cli: add support for legacy 'yoda1' format
Browse files Browse the repository at this point in the history
* Bump version to 0.2.2.
  • Loading branch information
GraemeWatt committed Nov 14, 2023
1 parent 01acff3 commit 39b3891
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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```.
Expand Down
4 changes: 2 additions & 2 deletions hepdata_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion hepdata_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
2 changes: 1 addition & 1 deletion hepdata_cli/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.1"
__version__ = "0.2.2"

0 comments on commit 39b3891

Please sign in to comment.