Compare commits

...

7 Commits

Author SHA1 Message Date
96a85feec0 Merge branch 'master' of https://github.com/Phyks/BMC 2016-01-10 17:59:41 +01:00
4dbc13e44c Add link to libbmc 2016-01-10 17:59:23 +01:00
c84159068c Merge pull request #33 from bcbnz/fixdoisearch
Search for Digital Object Identifier as well as DOI in text.
2015-12-07 19:08:20 +01:00
Blair Bonnett
330c2f2b5f Search for Digital Object Identifier as well as DOI in text.
If the paper identifier is marked with Digital Object Identifier, but
one or more of its references has a DOI link in it, then the reference
DOI is taken as the paper one. This change replaces the words Digital
Object Identifier with DOI in the text being searched to pull out the
correct ID.
2015-12-07 15:39:57 +13:00
Phyks
5f8665940d Fix unittests for Python 2.7 2015-09-05 16:55:14 +02:00
Phyks
f7bcdece5f Fix unittests for Python 2.7 2015-09-05 16:49:56 +02:00
Phyks
1b83f01581 Fix unittests 2015-09-05 16:46:11 +02:00
5 changed files with 11 additions and 9 deletions

View File

@ -5,6 +5,9 @@ BiblioManager is a simple script to download and store your articles. Read on if
**Note :** This script is currently a work in progress. **Note :** This script is currently a work in progress.
**Note: If you want to extract some functions from this repo, please consider using [libbmc](https://github.com/Phyks/libbmc/) instead, which is specifically dedicated to this (and this repo should be using it, rather than duplicating code).**
Travis build status : [![Build Status](https://travis-ci.org/Phyks/BMC.svg?branch=master)](https://travis-ci.org/Phyks/BMC) Travis build status : [![Build Status](https://travis-ci.org/Phyks/BMC.svg?branch=master)](https://travis-ci.org/Phyks/BMC)
## What is BiblioManager (or what it is **not**) ? ## What is BiblioManager (or what it is **not**) ?

View File

@ -22,7 +22,7 @@ try:
from urllib.error import URLError from urllib.error import URLError
except ImportError: except ImportError:
# Fall back to Python 2's urllib2 # Fall back to Python 2's urllib2
from urllib2 import urlopen, Request from urllib2 import urlopen, Request, URLError
import arxiv2bib as arxiv_metadata import arxiv2bib as arxiv_metadata
import libbmc.tools as tools import libbmc.tools as tools
import bibtexparser import bibtexparser
@ -213,15 +213,14 @@ def findArticleID(src, only=["DOI", "arXiv"]):
extractfull += ' '.join([i.decode(stdout_encoding).strip() for i in totext.stdout.readlines()]) extractfull += ' '.join([i.decode(stdout_encoding).strip() for i in totext.stdout.readlines()])
# Try to extract DOI # Try to extract DOI
if "DOI" in only: if "DOI" in only:
extractID = doi_re.search(extractfull.lower().replace('Œ', '-')) extractlower = extractfull.lower().replace('digital object identifier', 'doi')
extractID = doi_re.search(extractlower.replace('Œ', '-'))
if not extractID: if not extractID:
# PNAS fix # PNAS fix
extractID = doi_pnas_re.search(extractfull. extractID = doi_pnas_re.search(extractlower.replace('pnas', '/pnas'))
lower().
replace('pnas', '/pnas'))
if not extractID: if not extractID:
# JSB fix # JSB fix
extractID = doi_jsb_re.search(extractfull.lower()) extractID = doi_jsb_re.search(extractlower)
if extractID: if extractID:
extract_type = "DOI" extract_type = "DOI"
totext.terminate() totext.terminate()

View File

@ -8,5 +8,5 @@
number = {4}, number = {4},
author = {Yan-Hua Hou and Lev P. Pitaevskii and Sandro Stringari}, author = {Yan-Hua Hou and Lev P. Pitaevskii and Sandro Stringari},
title = {First and second sound in a highly elongated Fermi gas at unitarity}, title = {First and second sound in a highly elongated Fermi gas at unitarity},
journal = {Physical Review A} journal = {Phys. Rev. A}
} }

View File

@ -123,7 +123,7 @@ Lattice},
def test_getBibtex_id(self): def test_getBibtex_id(self):
bibtexAppend(self.bibtex_article) bibtexAppend(self.bibtex_article)
got = getBibtex(self.bibtex_article['ID'], file_id='ID') got = getBibtex(self.bibtex_article['ID'], file_id='id')
self.assertEqual(got, self.bibtex_article) self.assertEqual(got, self.bibtex_article)
def test_getBibtex_file(self): def test_getBibtex_file(self):

View File

@ -19,7 +19,7 @@ class TestTools(unittest.TestCase):
self.assertEqual(slugify(u"à&é_truc.pdf"), "ae_trucpdf") self.assertEqual(slugify(u"à&é_truc.pdf"), "ae_trucpdf")
def test_parsed2Bibtex(self): def test_parsed2Bibtex(self):
parsed = {'type': 'article', 'id': 'test', 'field1': 'test1', parsed = {'ENTRYTYPE': 'article', 'ID': 'test', 'field1': 'test1',
'field2': 'test2'} 'field2': 'test2'}
expected = ('@article{test,\n\tfield1={test1},\n' + expected = ('@article{test,\n\tfield1={test1},\n' +
'\tfield2={test2},\n}\n\n') '\tfield2={test2},\n}\n\n')