From 62ed4753cd6d42886a3a5196534e64028986ef48 Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Mon, 24 Dec 2018 13:10:48 +0530 Subject: [PATCH] Make python2 compat --- camelot/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/camelot/utils.py b/camelot/utils.py index 82aa493..8a95767 100644 --- a/camelot/utils.py +++ b/camelot/utils.py @@ -82,7 +82,11 @@ def download_url(url): filename = '{}.pdf'.format(random_string(6)) with tempfile.NamedTemporaryFile('wb', delete=False) as f: obj = urlopen(url) - if obj.info().get_content_type() != 'application/pdf': + if PY3: + content_type = obj.info().get_content_type() + else: + content_type = obj.info().getheader('Content-Type') + if content_type != 'application/pdf': raise NotImplementedError("File format not supported") f.write(obj.read()) filepath = os.path.join(os.path.dirname(f.name), filename)