|
13 | 13 | # SITE_URL = "http://127.0.0.1:5000" |
14 | 14 |
|
15 | 15 | UPLOAD_MAX_SIZE = 52000000 # Upload limit in bytes |
| 16 | +ALLOWED_FORMATS = ['csv', 'root', 'yaml', 'yoda', 'yoda1', 'yoda.h5', 'json'] |
16 | 17 |
|
17 | 18 | MAX_MATCHES, MATCHES_PER_PAGE = (10000, 10) if "pytest" not in sys.modules else (144, 12) |
18 | 19 |
|
@@ -82,7 +83,7 @@ def download(self, id_list, file_format=None, ids=None, table_name='', download_ |
82 | 83 | Downloads from the hepdata database the specified records. |
83 | 84 |
|
84 | 85 | :param id_list: list of ids to download. These can be obtained by the find function. |
85 | | - :param file_format: accepts one of ('csv', 'root', 'yaml', 'yoda', 'yoda1', 'json'). Specifies the download file format. |
| 86 | + :param file_format: accepts one of ('csv', 'root', 'yaml', 'yoda', 'yoda1', 'yoda.h5', 'json'). Specifies the download file format. |
86 | 87 | :param ids: accepts one of ('inspire', 'hepdata'). It specifies what type of ids have been passed. |
87 | 88 | :param table_name: restricts download to specific tables. |
88 | 89 | :param download_dir: defaults to ./hepdata-downloads. Specifies where to download the files. |
@@ -139,13 +140,14 @@ def _build_urls(self, id_list, file_format, ids, table_name): |
139 | 140 | if type(id_list) not in (tuple, list): |
140 | 141 | id_list = id_list.split() |
141 | 142 | assert len(id_list) > 0, 'Ids are required.' |
142 | | - assert file_format in ['csv', 'root', 'yaml', 'yoda', 'yoda1', 'json'], "allowed formats are: csv, root, yaml, yoda, yoda1 and json." |
| 143 | + assert file_format in ALLOWED_FORMATS, f"allowed formats are: {ALLOWED_FORMATS}" |
143 | 144 | assert ids in ['inspire', 'hepdata'], "allowed ids are: inspire and hepdata." |
144 | 145 | if table_name == '': |
145 | 146 | params = {'format': file_format} |
146 | 147 | else: |
147 | 148 | params = {'format': file_format, 'table': table_name} |
148 | | - urls = [resilient_requests('get', SITE_URL + '/record/' + ('ins' if ids == 'inspire' else '') + id_entry, params=params).url for id_entry in id_list] |
| 149 | + urls = [resilient_requests('get', SITE_URL + '/record/' + ('ins' if ids == 'inspire' else '') + id_entry, params=params).url.replace('%2525', '%25') for id_entry in id_list] |
| 150 | + # TODO: Investigate root cause of double URL encoding (https://github.com/HEPData/hepdata-cli/issues/8). |
149 | 151 | return urls |
150 | 152 |
|
151 | 153 | def _query(self, query, page, size): |
|
0 commit comments