summaryrefslogtreecommitdiff
path: root/bibtool/extract.py
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2018-03-24 17:22:29 +0100
committerRobin Krahl <me@robin-krahl.de>2018-03-24 17:22:29 +0100
commit54efba8e3b8fb20e506a31b3b9e452e1eccffe34 (patch)
treefb2d051c1b67139a09ae66d09a266efb24a15e3e /bibtool/extract.py
parent64037f9a53928ef3fb8b468d7abc2d15ecd1a28c (diff)
downloadbibtool-54efba8e3b8fb20e506a31b3b9e452e1eccffe34.tar.gz
bibtool-54efba8e3b8fb20e506a31b3b9e452e1eccffe34.tar.bz2
Add --doi option for explicit DOIs
Diffstat (limited to 'bibtool/extract.py')
-rw-r--r--bibtool/extract.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bibtool/extract.py b/bibtool/extract.py
index 6955dbe..cefbe8f 100644
--- a/bibtool/extract.py
+++ b/bibtool/extract.py
@@ -42,8 +42,9 @@ def _get_data_for_doi(doi):
return bibtexparser.loads(bibtex)
-def _handle_pdf(filename):
- doi = _extract_doi(filename)
+def _handle_pdf(filename, doi):
+ if not doi:
+ doi = _extract_doi(filename)
if not doi:
raise Exception('Could not extract a DOI from the PDF file')
@@ -51,8 +52,8 @@ def _handle_pdf(filename):
return _get_data_for_doi(doi)
-def get_bibtex_data(filename):
+def get_bibtex_data(filename, doi):
mtype, _ = mimetypes.guess_type(filename)
if mtype == 'application/pdf':
- return _handle_pdf(filename)
+ return _handle_pdf(filename, doi)
raise Exception('Unsupported file type ' + str(mtype))