How to use the quandl.util.Util.convert_options function in Quandl

To help you get started, we’ve selected a few Quandl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_get_request_with_dictionary_params_and_array_values(self):
        options = {'params': {'foo': {'bar': ['baz', 'bax']}}}
        expected_result = {'params': {'foo.bar[]': ['baz', 'bax']}}

        result = Util.convert_options(request_type='get', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_post_request_all_param_types(self):
        options = {'params': {'foo': 'bar',
                              'ticker': ['AAPL', 'MSFT'],
                              'per_end_date': {'gte': '2015-01-01'},
                              'qopts': {'columns': ['ticker', 'per_end_date'],
                                        'per_page': 5}}}
        expected_result = {'json': {'foo': 'bar',
                                    'qopts.per_page': 5,
                                    'per_end_date.gte': '2015-01-01',
                                    'ticker': ['AAPL', 'MSFT'],
                                    'qopts.columns': ['ticker', 'per_end_date']}}
        result = Util.convert_options(request_type='post', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_post_request_with_dictionary_params_and_array_values(self):
        options = {'params': {'foo': {'bar': ['baz', 'bax']}}}
        expected_result = {'json': {'foo.bar': ['baz', 'bax']}}

        result = Util.convert_options(request_type='post', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_get_request_with_empty_params(self):
        options = {'params': {}}
        expected_result = options

        result = Util.convert_options(request_type='get', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_post_request_with_empty_params(self):
        options = {'params': {}}
        expected_result = {'json': {}}

        result = Util.convert_options(request_type='post', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / test / test_util.py View on Github external
def test_convert_options_get_request_with_simple_params(self):
        options = {'params': {'foo': 'bar'}}
        expected_result = options

        result = Util.convert_options(request_type='get', **options)
        self.assertEqual(cmp(result, expected_result), 0)
github quandl / quandl-python / quandl / model / datatable.py View on Github external
def _request_file_info(self, file_or_folder_path, **options):
        url = self._download_request_path()
        code_name = self.code
        options['params']['qopts.export'] = 'true'

        request_type = RequestType.get_request_type(url, **options)

        updated_options = Util.convert_options(request_type=request_type, **options)

        r = Connection.request(request_type, url, **updated_options)

        response_data = r.json()

        file_info = response_data['datatable_bulk_download']['file']

        status = file_info['status']

        if status == 'fresh':
            file_link = file_info['link']
            self._download_file_with_link(file_or_folder_path, file_link, code_name)
            return True
        else:
            return False
github quandl / quandl-python / quandl / operations / list.py View on Github external
def page(cls, datatable, **options):
        params = {'id': str(datatable.code)}
        path = Util.constructed_path(datatable.default_path(), params)

        request_type = RequestType.get_request_type(path, **options)

        updated_options = Util.convert_options(request_type=request_type, **options)

        r = Connection.request(request_type, path, **updated_options)

        response_data = r.json()
        Util.convert_to_dates(response_data)
        resource = cls.create_datatable_list_from_response(response_data)
        return resource