Skip to content

Commit

Permalink
Use six.moves instead of try/except ImportError, reorder imports (q…
Browse files Browse the repository at this point in the history
…uandl#129)

* Use `six.moves` instead of `try/except ImportError`, reorder imports

* Update test_datatable.py
  • Loading branch information
42B authored and A-Scott-Rowe committed Feb 6, 2019
1 parent 985e1a7 commit 589fe3c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 42 deletions.
15 changes: 5 additions & 10 deletions quandl/model/database.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
try:
from urllib.parse import urlparse
from urllib.parse import urlencode
except ImportError:
from urlparse import urlparse
from urllib import urlencode

import os

from six.moves.urllib.parse import urlencode, urlparse

import quandl.model.dataset
from quandl.api_config import ApiConfig
from quandl.connection import Connection
from quandl.util import Util
from quandl.errors.quandl_error import QuandlError
from quandl.message import Message
from quandl.operations.get import GetOperation
from quandl.operations.list import ListOperation
from quandl.util import Util
from .model_base import ModelBase
from quandl.message import Message
import quandl.model.dataset


class Database(GetOperation, ListOperation, ModelBase):
Expand Down
16 changes: 6 additions & 10 deletions quandl/model/datatable.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen

from time import sleep
import os
from time import sleep

from six.moves.urllib.request import urlopen

from quandl.connection import Connection
from quandl.util import Util
from quandl.errors.quandl_error import QuandlError
from quandl.message import Message
from quandl.operations.get import GetOperation
from quandl.operations.list import ListOperation
from quandl.util import Util
from quandl.utils.request_type_util import RequestType

from .model_base import ModelBase
from quandl.message import Message
from .data import Data
from .model_base import ModelBase


class Datatable(GetOperation, ListOperation, ModelBase):
Expand Down
22 changes: 9 additions & 13 deletions test/test_database.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
try:
from urllib.parse import urlparse
from urllib.parse import parse_qs
except ImportError:
from urlparse import urlparse
from cgi import parse_qs

import json
import re
import unittest
from test.helpers.httpretty_extension import httpretty
import json

import six
from quandl.errors.quandl_error import (InternalServerError, QuandlError)
from mock import call, mock_open, patch
from six.moves.urllib.parse import parse_qs, urlparse

from quandl.api_config import ApiConfig
from quandl.model.database import Database
from quandl.connection import Connection
from test.test_retries import ModifyRetrySettingsTestCase
from mock import patch, call, mock_open
from quandl.errors.quandl_error import (InternalServerError, QuandlError)
from quandl.model.database import Database
from test.factories.database import DatabaseFactory
from test.factories.meta import MetaFactory
from test.helpers.httpretty_extension import httpretty
from test.test_retries import ModifyRetrySettingsTestCase


class GetDatabaseTest(unittest.TestCase):
Expand Down
16 changes: 7 additions & 9 deletions test/test_datatable.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse

import json
import re
import unittest

import httpretty
import json
import six
from mock import call, mock_open, patch
from six.moves.urllib.parse import urlparse

from quandl.api_config import ApiConfig
from quandl.errors.quandl_error import (InternalServerError, QuandlError)
from quandl.model.datatable import Datatable
from mock import patch, call, mock_open
from test.factories.datatable import DatatableFactory
from test.test_retries import ModifyRetrySettingsTestCase
from quandl.api_config import ApiConfig
from quandl.utils.request_type_util import RequestType
from quandl.errors.quandl_error import (InternalServerError, QuandlError)
from parameterized import parameterized


Expand Down

0 comments on commit 589fe3c

Please sign in to comment.