--- pdf2bib.py-orig 2014-10-12 18:18:29.561977936 -0300
+++ pdf2bib.py 2014-10-12 18:16:44.258557846 -0300
@@ -33,7 +33,7 @@
import os
import subprocess
import re
-from urllib import request
+import urllib2
import argparse
@@ -97,8 +97,8 @@
def get_bibtex(self, doi):
"""Return bibtex entry by doi"""
- req = request.Request(self.url.format(doi=doi), headers=self.headers)
- f = request.urlopen(req)
+ req = urllib2.Request(self.url.format(doi=doi), headers=self.headers)
+ f = urllib2.urlopen(req)
return f.read().decode('utf-8')
@@ -166,7 +166,7 @@
# gather files to analyze
f = list()
for location in args.location:
- if os.path.isfile(location) and ".pdf" in location.tolower():
+ if os.path.isfile(location) and ".pdf" in location:
f.append(location)
elif os.path.isdir(location):
for (path, _, files) in os.walk(location):
@@ -179,9 +179,13 @@
if doi:
print(" .. Found DOI: {}".format(doi))
print(" .. Fetching Metadata...")
- b = BibEntry(bibtex.get_bibtex(doi))
+ b = BibEntry(bibtex.get_bibtex(doi).encode("utf-8"))
b.add_arg('file', file)
- args.output.write(b.format(exclude=args.exclude.split(",")))
+ if args.exclude:
+ exclude = args.exclude.split(",")
+ else:
+ exclude = []
+ args.output.write(b.format(exclude))
args.output.write("\n\n")
print(" .. Wrote Entry. ")
else:
domingo, 12 de outubro de 2014
pdf2bib.py (https://github.com/janoliver/pdf2bib) / python 2.7.5 /patch
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário