Skip to content

Commit 3e8a9df

Browse files
committed
README: replace arxiv-cli example with arxiv.py
* The arxiv-cli package has not been updated since 2018. * Installation problems (e.g. jacquerie/arxiv-cli#10). * arxiv.py is a more modern Python API (but no CLI). * Also remove statement about Python 2 compatibility. * Insert space after "P P" and before "-->" in reactions.
1 parent b4a0b33 commit 3e8a9df

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

README.md

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
Command line interface (CLI) and application program interface (API) to allow users to search, download from and upload to [HEPData](https://www.hepdata.net).
1414

15-
The code is compatible with both Python 2 and Python 3. Inspiration from [arxiv-cli](https://github.com/jacquerie/arxiv-cli).
15+
The code is compatible with Python 3.7 or greater. Inspiration from [arxiv-cli](https://github.com/jacquerie/arxiv-cli) (unmaintained since 2018).
1616

1717
## Installation (for users)
1818

@@ -85,7 +85,6 @@ The argument ```[-p/--password PASSWORD``` is the password for the uploader's HE
8585
Warning: do not store your password unencrypted in any code intended for shared use.
8686

8787
The ```hepdata-cli download/fetch-names``` and ```hepdata-cli find``` commands can be concatenated, if a ```IDTYPE``` is specified for ```find```.
88-
It is also possible to concatenate ```arxiv download```, form [pypi/arxiv-cli](https://pypi.org/project/arxiv-cli/), with ```hepdata-cli find```, if ```arxiv``` is used as ```IDTYPE```.
8988

9089
## API
9190

@@ -106,55 +105,55 @@ client.upload(path_to_file, email, recid, invitation_cookie, sandbox, password)
106105
### Example 1 - a plain search:
107106

108107
```code
109-
$ hepdata-cli --verbose find 'reactions:"P P--> LQ LQ X"'
108+
$ hepdata-cli --verbose find 'reactions:"P P --> LQ LQ X"'
110109
```
111110

112111
or equivalently
113112

114113
```python
115-
client.find('reactions:"P P--> LQ LQ X"')
114+
client.find('reactions:"P P --> LQ LQ X"')
116115
```
117116

118117
matches a single entry and returns full metadata dictionary.
119118

120119
### Example 2 - search with keyword:
121120

122121
```code
123-
$ hepdata-cli --verbose find 'reactions:"P P--> LQ LQ"' -kw year
122+
$ hepdata-cli --verbose find 'reactions:"P P --> LQ LQ"' -kw year
124123
```
125124

126125
or equivalently
127126

128127
```python
129-
client.find('reactions:"P P--> LQ LQ"', keyword='year')
128+
client.find('reactions:"P P --> LQ LQ"', keyword='year')
130129
```
131130

132131
matches four entries and returns their publication years, as a dictionary.
133132

134133
### Example 3 - search for ids of records:
135134

136135
```code
137-
$ hepdata-cli --verbose find 'reactions:"P P--> LQ LQ"' -i hepdata
136+
$ hepdata-cli --verbose find 'reactions:"P P --> LQ LQ"' -i hepdata
138137
```
139138

140139
or equivalently
141140

142141
```python
143-
client.find('reactions:"P P--> LQ LQ"', ids='hepdata')
142+
client.find('reactions:"P P --> LQ LQ"', ids='hepdata')
144143
```
145144

146145
matches four entries and returns their hepdata ids, as a plain list.
147146

148147
### Example 4 - concatenate search with download using inspire ids:
149148

150149
```code
151-
$ hepdata-cli --verbose download $(hepdata-cli find 'reactions:"P P--> LQ LQ"' -i inspire) -i inspire -f csv
150+
$ hepdata-cli --verbose download $(hepdata-cli find 'reactions:"P P --> LQ LQ"' -i inspire) -i inspire -f csv
152151
```
153152

154153
or equivalently
155154

156155
```python
157-
id_list = client.find('reactions:"P P--> LQ LQ"', ids='inspire')
156+
id_list = client.find('reactions:"P P --> LQ LQ"', ids='inspire')
158157
downloads = client.download(id_list, ids='inspire', file_format='csv')
159158
print(downloads) # {'1222326': ['./hepdata-downloads/HEPData-ins1222326-v1-csv/Table1.csv', ...], ...}
160159
```
@@ -164,47 +163,42 @@ downloads four .tar.gz archives containing csv files and unpacks them in the def
164163
### Example 5 - find table names in records:
165164

166165
```code
167-
$ hepdata-cli fetch-names $(hepdata-cli find 'reactions:"P P--> LQ LQ"' -i hepdata) -i hepdata
166+
$ hepdata-cli fetch-names $(hepdata-cli find 'reactions:"P P --> LQ LQ"' -i hepdata) -i hepdata
168167
```
169168

170169
or equivalently
171170

172171
```python
173-
id_list = client.find('reactions:"P P--> LQ LQ"', ids='hepdata')
172+
id_list = client.find('reactions:"P P --> LQ LQ"', ids='hepdata')
174173
client.fetch_names(id_list, ids='hepdata')
175174
```
176175

177176
returns all table names in the four matching records.
178177

179-
### Example 6 - concatenate search with download from arxiv-cli:
178+
### Example 6 - combine search with download from arxiv:
180179

181-
This example requires [arxiv-cli](https://github.com/jacquerie/arxiv-cli) to be installed, which is easily done via:
180+
This example requires [arxiv.py](https://github.com/lukasschwab/arxiv.py) to be installed, which is easily done via:
182181

183182
```code
184-
$ pip install --user arxiv-cli
183+
$ pip install --user arxiv
185184
```
186185

187-
Note that arxiv-cli installs an older version of [click](https://pypi.org/project/click/) which changes the CLI command
188-
in Example 5 above from ```fetch-names``` to ```fetch_names```.
189-
190186
Then,
191187

192-
```code
193-
$ arxiv download $(hepdata-cli find 'reactions:"P P--> LQ LQ"' -i arxiv)
194-
```
195-
196-
or equivalently
197-
198188
```python
199-
import arxiv_cli
200189
import hepdata_cli
201-
arxiv_client = arxiv_cli.Client()
202190
hepdata_client = hepdata_cli.Client()
203-
id_list = hepdata_client.find('reactions:"P P--> LQ LQ"', ids='arxiv')
204-
arxiv_client.download(id_list)
191+
id_list = hepdata_client.find('reactions:"P P --> LQ LQ X"', ids='arxiv')
192+
id_list = id_list.split()
193+
print(id_list) # ['1605.06035', '2101.11582', ...]
194+
195+
import arxiv
196+
papers = arxiv.Client().results(arxiv.Search(id_list=id_list))
197+
for paper in papers:
198+
paper.download_pdf()
205199
```
206200

207-
downloads two pdfs from the arXiv.
201+
downloads the PDF files from the arXiv.
208202

209203
### Example 7 - upload record to the sandbox:
210204

tests/test_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# arguments for testing
1212

1313
test_api_find_arguments = [
14-
('reactions:"P P--> LQ LQ X"', None, None),
15-
('reactions:"P P--> LQ LQ"', 'year', None),
14+
('reactions:"P P --> LQ LQ X"', None, None),
15+
('reactions:"P P --> LQ LQ"', 'year', None),
1616
('phrases:"(diffractive AND elastic)"', None, 'arxiv'),
1717
]
1818

0 commit comments

Comments
 (0)