Flake8 fixes
This commit is contained in:
parent
35541a43e6
commit
7fda1bd5fa
@ -1,4 +1,2 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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 ''
|
||||||
|
@ -21,7 +21,7 @@ class TestFetcher(unittest.TestCase):
|
|||||||
config.set("folder", tempfile.mkdtemp()+"/")
|
config.set("folder", tempfile.mkdtemp()+"/")
|
||||||
self.bibtex_article_string = """
|
self.bibtex_article_string = """
|
||||||
@article{1303.3130v1,
|
@article{1303.3130v1,
|
||||||
abstract={We study the role of the dipolar interaction, correctly accounting for the
|
abstract={We study the role of the dipolar interaction, correctly accounting for the
|
||||||
Dipolar-Induced Resonance (DIR), in a quasi-one-dimensional system of ultracold
|
Dipolar-Induced Resonance (DIR), in a quasi-one-dimensional system of ultracold
|
||||||
bosons. We first show how the DIR affects the lowest-energy states of two
|
bosons. We first show how the DIR affects the lowest-energy states of two
|
||||||
particles in a harmonic trap. Then, we consider a deep optical lattice loaded
|
particles in a harmonic trap. Then, we consider a deep optical lattice loaded
|
||||||
@ -30,17 +30,17 @@ atom-dimer extended Bose-Hubbard model. We analyze the impact of the DIR on the
|
|||||||
phase diagram at T=0 by exact diagonalization of a small-sized system. In
|
phase diagram at T=0 by exact diagonalization of a small-sized system. In
|
||||||
particular, the resonance strongly modifies the range of parameters for which a
|
particular, the resonance strongly modifies the range of parameters for which a
|
||||||
mass density wave should occur.},
|
mass density wave should occur.},
|
||||||
archiveprefix={arXiv},
|
archiveprefix={arXiv},
|
||||||
author={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati},
|
author={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati},
|
||||||
eprint={1303.3130v1},
|
eprint={1303.3130v1},
|
||||||
file={%sN_Bartolo_A_Recati-j-2013.pdf},
|
file={%sN_Bartolo_A_Recati-j-2013.pdf},
|
||||||
link={http://arxiv.org/abs/1303.3130v1},
|
link={http://arxiv.org/abs/1303.3130v1},
|
||||||
month={Mar},
|
month={Mar},
|
||||||
primaryclass={cond-mat.quant-gas},
|
primaryclass={cond-mat.quant-gas},
|
||||||
tag={},
|
tag={},
|
||||||
title={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical
|
title={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical
|
||||||
Lattice},
|
Lattice},
|
||||||
year={2013},
|
year={2013},
|
||||||
}""" % config.get("folder")
|
}""" % config.get("folder")
|
||||||
self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict()
|
self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict()
|
||||||
self.bibtex_article = self.bibtex_article[self.bibtex_article.keys()[0]]
|
self.bibtex_article = self.bibtex_article[self.bibtex_article.keys()[0]]
|
||||||
|
Loading…
Reference in New Issue
Block a user