From 52eaa4b6639860227e751c9593fc8ac371c7501a Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 8 Aug 2016 23:18:00 -0400 Subject: [PATCH] Didn't think 2.7/3.x compatibility would be this bad... --- .idea/inspectionProfiles/Project_Default.xml | 19 +++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 7 ++++++ .idea/misc.xml | 5 +++- metrik/tasks/bloomberg.py | 24 +++++++------------ setup.py | 3 ++- 5 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..3dd7c96 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 90bd2cd..dd1ff53 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -48,7 +48,10 @@ - + + + \ No newline at end of file diff --git a/metrik/tasks/bloomberg.py b/metrik/tasks/bloomberg.py index 9e79d27..f8abc9c 100644 --- a/metrik/tasks/bloomberg.py +++ b/metrik/tasks/bloomberg.py @@ -2,15 +2,11 @@ import requests from luigi import Task, Parameter from pyquery import PyQuery as pq import logging - -try: - from urllib.parse import quote_plus - from html.parser import HTMLParser -except ImportError: - # noinspection PyUnresolvedReferences - from urllib import quote_plus - # noinspection PyUnresolvedReferences - from HTMLParser import HTMLParser +# noinspection PyUnresolvedReferences +from six.moves.urllib.parse import quote_plus +# noinspection PyUnresolvedReferences +from six.moves.html_parser import HTMLParser +from six import PY2 class BloombergEquityInfo(Task): @@ -20,15 +16,11 @@ class BloombergEquityInfo(Task): @staticmethod def retrieve_info(bbg_code, user_agent): class EquityInfoParser(HTMLParser): - def __init__(self, keys): - # This call isn't safe because python 2 HTMLParser is an - # old-style class - try: + if PY2: + HTMLParser.__init__(self) + else: super(EquityInfoParser, self).__init__() - except TypeError: - pass - self.keys = keys self.records = {k: None for k in keys} self.do_record = {k: False for k in keys} diff --git a/setup.py b/setup.py index 01bf184..99a0580 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,8 @@ setup( install_requires=[ 'pyquery >= 1.2.13', 'luigi >= 2.2.0', - 'requests >= 2.9.1' + 'requests >= 2.9.1', + 'six >= 1.10.0' ], setup_requires=[ 'pytest_runner'