Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request #92

Closed
chackoge opened this issue Dec 21, 2020 · 3 comments
Closed

Feature Request #92

chackoge opened this issue Dec 21, 2020 · 3 comments
Milestone

Comments

@chackoge
Copy link

chackoge commented Dec 21, 2020

Hello- when submitting a list of DOIs to content_negotiation as below, if one of the DOIs isn't found no data is returned and an error is returned. Is there a way to return 'doi not found' and process the rest of the data? Thanks

Python 3.8.2 (default, Nov 4 2020, 21:23:28)
habanero 0.7.4

from habanero import cn
print(testlist)

['10.1126/science.169.3946.635', '10.1162/qss_a_00007', '10.1126/science.169.3946.637'] # the third DOI doesn't exist

cn.content_negotiation(ids = kws[0:2],format='bibtex')

['@Article{Frank_1970,\n\tdoi = {10.1126/science.169.3946.635},\n\turl = {https://doi.org/10.1126%2Fscience.169.3946.635},\n\tyear = 1970,\n\tmonth = {aug},\n\tpublisher = {American Association for the Advancement of Science ({AAAS})},\n\tvolume = {169},\n\tnumber = {3946},\n\tpages = {635--641},\n\tauthor = {H. S. Frank},\n\ttitle = {The Structure of Ordinary Water: New data and interpretations are yielding new insights into this fascinating substance},\n\tjournal = {Science}\n}',
'@Article{Bradley_2020,\n\tdoi = {10.1162/qss_a_00007},\n\turl = {https://doi.org/10.1162%2Fqss_a_00007},\n\tyear = 2020,\n\tmonth = {feb},\n\tpublisher = {{MIT} Press - Journals},\n\tvolume = {1},\n\tnumber = {1},\n\tpages = {264--276},\n\tauthor = {James Bradley and Sitaram Devarakonda and Avon Davey and Dmitriy Korobskiy and Siyu Liu and Djamil Lakhdar-Hamina and Tandy Warnow and George Chacko},\n\ttitle = {Co-citations in context: Disciplinary heterogeneity is relevant},\n\tjournal = {Quantitative Science Studies}\n}']

cn.content_negotiation(ids = kws[0:3],format='bibtex')

HTTPError Traceback (most recent call last)
in
----> 1 cn.content_negotiation(ids = kws[0:3],format='bibtex')

/opt/anaconda3/lib/python3.8/site-packages/habanero/cn/cn.py in content_negotiation(ids, format, style, locale, url, **kwargs)
80 if url is None:
81 url = cn_base_url
---> 82 return CNRequest(url, ids, format, style, locale, **kwargs)

/opt/anaconda3/lib/python3.8/site-packages/habanero/cnrequest.py in CNRequest(url, ids, format, style, locale, **kwargs)
29 coll = []
30 for i in range(len(ids)):
---> 31 tt = make_request(url, ids[i], format, style, locale, **kwargs)
32 coll.append(tt)
33

/opt/anaconda3/lib/python3.8/site-packages/habanero/cnrequest.py in make_request(url, ids, format, style, locale, **kwargs)
52
53 # Raise an HTTPError if the status code of the response is 4XX or 5XX
---> 54 response.raise_for_status()
55
56 # set encoding

/opt/anaconda3/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
939
940 if http_error_msg:
--> 941 raise HTTPError(http_error_msg, response=self)
942
943 def close(self):

HTTPError: 404 Client Error: for url: https://doi.org/10.1126/science.169.3946.637

@sckott sckott added this to the v0.8 milestone Dec 22, 2020
sckott added a commit that referenced this issue Dec 22, 2020
@sckott
Copy link
Owner

sckott commented Dec 22, 2020

thanks for the issue @chackoge

see also #69

reinstall from here and try again, let me know if it works for you - updated docs here https://habanero.readthedocs.io/en/latest/modules/cn.html#module-habanero with info on warnings

@chackoge
Copy link
Author

chackoge commented Dec 22, 2020

Works great thank you very much. I like throwing an error when only a single DOI is provided. It's a great client.
Being new to Python I ran
pip install --force-reinstall habanero
a couple of times to no effect before realizing that I needed to run
pip install --force-reinstall git+git://github.com/sckott/habanero.git#egg=habanero
I did see #69 but since it related to works rather then cn, I wasn't sure whether to create a new request but eventually did.

@sckott
Copy link
Owner

sckott commented Dec 22, 2020

Was just pinging the other issue as a note to myself so I don't forget about them covering the same topic.

I don't understand very well install from github for python, so I can't help much there - so glad that worked for you.

@sckott sckott closed this as completed Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants