Flake8 fixes

This commit is contained in:
Phyks 2014-08-03 00:17:01 +02:00
parent 35541a43e6
commit 7fda1bd5fa
5 changed files with 22 additions and 23 deletions

View File

@ -1,4 +1,2 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-

View File

@ -12,8 +12,8 @@
import os import os
import re import re
import libbmc.tools import libbmc.tools as tools
import libbmc.fetcher import libbmc.fetcher as fetcher
from bibtexparser.bparser import BibTexParser from bibtexparser.bparser import BibTexParser
from libbmc.config import Config from libbmc.config import Config
from codecs import open from codecs import open

View File

@ -4,7 +4,7 @@ import imp
import inspect import inspect
import json import json
import sys import sys
import libbmc.tools import libbmc.tools as tools
# List of available options (in ~/.config/bmc/bmc.json file): # List of available options (in ~/.config/bmc/bmc.json file):
# * folder : folder in which papers are stored # * folder : folder in which papers are stored

View File

@ -18,13 +18,13 @@ import subprocess
import sys import sys
try: try:
# For Python 3.0 and later # For Python 3.0 and later
from urllib.request import urlopen from urllib.request import urlopen, Request
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, URLError from urllib2 import urlopen, Request, URLError
import arxiv2bib as arxiv_metadata import arxiv2bib as arxiv_metadata
import libbmc.tools import libbmc.tools as tools
from bibtexparser.bparser import BibTexParser from bibtexparser.bparser import BibTexParser
from libbmc.config import Config from libbmc.config import Config
@ -230,14 +230,15 @@ def doi2Bib(doi):
""" """
url = "http://dx.doi.org/" + doi url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"} headers = {"accept": "application/x-bibtex"}
req = Request(url, headers=headers)
try: try:
r = requests.get(url, headers=headers) r = urlopen(req)
if r.headers['content-type'] == 'application/x-bibtex': if r.headers.getheader('content-type') == 'application/x-bibtex':
return r.text return r.read()
else: else:
return '' return ''
except requests.exceptions.ConnectionError: except URLError:
tools.warning('Unable to contact remote server to get the bibtex ' + tools.warning('Unable to contact remote server to get the bibtex ' +
'entry for doi '+doi) 'entry for doi '+doi)
return '' return ''