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
# -*- coding: utf-8 -*-

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ class TestFetcher(unittest.TestCase):
config.set("folder", tempfile.mkdtemp()+"/")
self.bibtex_article_string = """
@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
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
@ -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
particular, the resonance strongly modifies the range of parameters for which a
mass density wave should occur.},
archiveprefix={arXiv},
author={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati},
eprint={1303.3130v1},
file={%sN_Bartolo_A_Recati-j-2013.pdf},
link={http://arxiv.org/abs/1303.3130v1},
month={Mar},
primaryclass={cond-mat.quant-gas},
tag={},
title={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical
archiveprefix={arXiv},
author={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati},
eprint={1303.3130v1},
file={%sN_Bartolo_A_Recati-j-2013.pdf},
link={http://arxiv.org/abs/1303.3130v1},
month={Mar},
primaryclass={cond-mat.quant-gas},
tag={},
title={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical
Lattice},
year={2013},
year={2013},
}""" % config.get("folder")
self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict()
self.bibtex_article = self.bibtex_article[self.bibtex_article.keys()[0]]