Skip to content

Commit

Permalink
This checks the short-container-title filed before making the replace…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
devmessias committed Jul 16, 2020
1 parent 9d2ab39 commit e8ab193
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": true,
"python.linting.enabled": true
"python.linting.pycodestyleEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
7 changes: 4 additions & 3 deletions doi2bib/crossref.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_bib(doi):
bib = r.content
bib = str(bib, "utf-8")

return found, bib
return found, bib


def get_json(doi):
Expand Down Expand Up @@ -65,8 +65,9 @@ def get_bib_from_doi(doi, abbrev_journal=True):

found, item = get_json(doi)
if found:
abbreviated_journal = item["message"]["short-container-title"][0].strip()
if abbreviated_journal:
abbreviated_journal = item["message"]["short-container-title"]
if len(abbreviated_journal) > 0:
abbreviated_journal = abbreviated_journal[0].strip()
bib = re.sub(
r"journal = \{[^>]*?\}",
"journal = {" + abbreviated_journal + "}",
Expand Down

0 comments on commit e8ab193

Please sign in to comment.