Last active
October 6, 2019 09:41
-
-
Save rieder/2986c76ca1865929bc5de4e78f41fe4e to your computer and use it in GitHub Desktop.
Create an entry for the AMUSE papers database based on citekey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import ads | |
# from amuse.support.version import major_version, minor_version | |
major_version = 12 | |
minor_version = 1 | |
ver = "%s.%s" % (major_version, minor_version) | |
bibcodes = sys.argv[1:] | |
for bibcode in bibcodes: | |
article = list(ads.SearchQuery(bibcode=bibcode))[0] | |
authors = article.author | |
title = article.title[0] | |
doi = article.doi[0] | |
# citecode = article.bibcode | |
if len(authors) > 1: | |
author_field = authors[0] + " et al." | |
i = 0 | |
title_field_width = 42 | |
if len(title) > title_field_width: | |
title_words = title.split(' ') | |
title_field = "" | |
line_length = 0 | |
while i < len(title_words): | |
if line_length < title_field_width: | |
if i > 0: | |
title_field += " " | |
line_length += 1 | |
title_field += title_words[i] | |
line_length += len(title_words[i]) | |
i += 1 | |
else: | |
title_field += "<br>" | |
line_length = 0 | |
else: | |
title_field = title | |
print( | |
"%s | [%s](https://ui.adsabs.harvard.edu/abs/%s/abstract) | %s | n/a" | |
% ( | |
author_field, | |
title_field, | |
bibcode, | |
ver, | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment