diff --git a/.appveyor.yml b/.appveyor.yml index bf7b6366..62de9157 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,5 +14,4 @@ build: off test_script: - cd .. - #- "if %PYTHON%==C:\\Python36-x64 (%PYTHON%\\python -m pytest pymarketcap/tests -vs --end2end) else (%PYTHON%\\python -m pytest pymarketcap/tests -vs)" - - tox \ No newline at end of file + - "if %PYTHON%==C:\\Python36-x64 (%PYTHON%\\python -m pytest pymarketcap/tests -vs --end2end) else (%PYTHON%\\python -m pytest pymarketcap/tests -vs)" diff --git a/.travis.yml b/.travis.yml index 68b9d6c6..50e27763 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,23 @@ os: - linux python: + - "3.6" - "3.6.3" + - "3.6.4" + - "nightly" - "3.7-dev" install: # urllib version in Python3.6 - pip install -r dev-requirements.txt - - if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then make install-light; else make install; fi + - if [[ $TRAVIS_PYTHON_VERSION == "3.6" ]]; then make install-light; else make install; fi before_script: - python -m pip install --upgrade pip - echo $TRAVIS_PYTHON_VERSION script: - - tox + - if [[ $TRAVIS_PYTHON_VERSION == "3.6" ]]; then make test-end2end; else make test; fi branches: only: - master after_success: - - if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then coveralls; fi + - if [[ $TRAVIS_PYTHON_VERSION == "3.6" ]]; then coveralls; fi diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index b16dc9e4..4de39df6 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -45,7 +45,7 @@ TODO - Add posibility of return asynchronous responses in ``pandas.DataFrames`` objects or download it in ``.csv`` format. - Include links to source code in documentation reference. - Assert names consistence in responses fields between methods. - +- Reintegrate support for Python3.6.4 -------------- How does pymarketcap works in depth? diff --git a/Makefile b/Makefile index 199d6cff..7d65b5cf 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,8 @@ reinstall: clean: sudo rm -Rf .pytest_cache/ .tox/ build/ dist/ pymarketcap.egg-info/ sudo find . -type d -name "__pycache__" -exec rm -r {} + - sudo rm pymarketcap/*.c pymarketcap/*.so sudo find . -type d -name "_build" -exec rm -r {} + + sudo rm pymarketcap/*.c pymarketcap/*.so test: pytest tests -vs diff --git a/README.rst b/README.rst index b2b10112..2c0256ec 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ pymarketcap `coinmarketcap `__ API and website. Consist of a cythonized scraper and and API wrapper built with libcurl, but is posible to compile a lightweight version with standard ``urllib`` -library instead. Only works in Python3.6+ +library instead. Only works in Python3.7+ Install ------- diff --git a/dev-requirements.txt b/dev-requirements.txt index dbaab24d..47678005 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,4 @@ pytest>=3.4.0 -tox>=3.0.0rc1 tqdm>=4.19.5 tabulate>=0.8.2 sphinx>=1.7.0 diff --git a/pymarketcap/__init__.py b/pymarketcap/__init__.py index 662292ee..4b4d01d3 100644 --- a/pymarketcap/__init__.py +++ b/pymarketcap/__init__.py @@ -5,7 +5,7 @@ import sys __title__ = "pymarketcap" -__version__ = "3.9.142" +__version__ = "3.9.144" __version_info__ = (int(num) for num in __version__.split(".")) __author__ = "Alvaro Mondejar Rubio " __repo__ = "https://github.com/mondeja/pymarketcap" diff --git a/pymarketcap/core.pyx b/pymarketcap/core.pyx index 30bf99a0..83ce3ef3 100644 --- a/pymarketcap/core.pyx +++ b/pymarketcap/core.pyx @@ -323,7 +323,10 @@ cdef class Pymarketcap: @property def ticker_badges(self): """Badges in wich you can convert prices in ``ticker()`` method.""" - return + return ["AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", + "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", + "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", + "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "USD", "ZAR"] cpdef ticker(self, currency=None, limit=0, start=0, convert="USD"): """Get currencies with other aditional data. @@ -347,13 +350,12 @@ cdef class Pymarketcap: Returns (dict/list): The type depends if currency param is provided or not. """ - cdef bytes url cdef short i, len_i if not currency: - url = b"https://api.coinmarketcap.com/v1/ticker/?%s" % b"limit=%d" % limit - url += b"&start=%d" % start - url += b"&convert=%s" % convert.encode() - res = self._get(url) + url = "https://api.coinmarketcap.com/v1/ticker/?limit=%d" % limit + url += "&start=%d" % start + url += "&convert=%s" % convert + res = self._get(url.encode()) response = loads(re_sub(r'"(-*\d+(?:\.\d+)?)"', r"\1", res)) len_i = len(response) for i in range(len_i): @@ -361,9 +363,9 @@ cdef class Pymarketcap: else: if self._is_symbol(currency): currency = self.correspondences[currency] - url = b"https://api.coinmarketcap.com/v1/ticker/%s" % currency.encode() - url += b"?convert=%s" % convert.encode() - res = self._get(url) + url = "https://api.coinmarketcap.com/v1/ticker/%s" % currency + url += "?convert=%s" % convert + res = self._get(url.encode()) response = loads(re_sub(r'"(-*\d+(?:\.\d+)?)"', r"\1", res))[0] response["symbol"] = str(response["symbol"]) return response @@ -533,7 +535,6 @@ cdef class Pymarketcap: Returns (list): Historical dayly OHLC for a currency. """ - cdef bytes url, _start, _end response = {} if self._is_symbol(name): @@ -547,13 +548,13 @@ cdef class Pymarketcap: response["symbol"] = symbol break - url = b"https://coinmarketcap.com/currencies/%s/historical-data/" % name.encode() - _start = b"%d" % start.year + b"%02d" % start.month + b"%02d" % start.day - _end = b"%d" % end.year + b"%02d" % end.month + b"%02d" % end.day - url += b"?start=%s" % _start + b"&" + b"end=%s" % _end + url = "https://coinmarketcap.com/currencies/%s/historical-data/" % name + _start = "%d" % start.year + "%02d" % start.month + "%02d" % start.day + _end = "%d" % end.year + "%02d" % end.month + "%02d" % end.day + url += "?start=%s" % _start + "&" + "end=%s" % _end try: - res = self._get(url)[50000:] + res = self._get(url.encode())[50000:] except CoinmarketcapHTTPError404: if name not in self.coins: raise ValueError("%s is not a valid currrency name. See 'symbols'" % name \ @@ -596,10 +597,9 @@ cdef class Pymarketcap: Data from a exchange. Keys: ``"name"``, ``"website"``, ``"volume"`` (total), ``"social"`` and ``"markets"``. """ - cdef bytes url - url = b"https://coinmarketcap.com/exchanges/%s/" % name.encode() + url = "https://coinmarketcap.com/exchanges/%s/" % name try: - res = self._get(url)[20000:] + res = self._get(url.encode())[20000:] except CoinmarketcapHTTPError404: if name not in self.exchange_slugs: raise ValueError("%s is not a valid exchange name. See exchange_slugs" % name \ diff --git a/pymarketcap/curl.pyx b/pymarketcap/curl.pyx index 999fcbee..88428046 100644 --- a/pymarketcap/curl.pyx +++ b/pymarketcap/curl.pyx @@ -39,7 +39,7 @@ cpdef Response get_to_memory(const char *url, long timeout, bint debug): cdef long true = 1L version = curl_version() cdef CURL *curl = curl_easy_init() - cdef const char *user_agent = "pymarketcap 3.9.142" + cdef const char *user_agent = "pymarketcap 3.9.144" cdef const char *accept_encoding = "gzip, deflate" cdef char *raw_body diff --git a/setup.py b/setup.py index 432237a4..53a5a058 100644 --- a/setup.py +++ b/setup.py @@ -156,8 +156,7 @@ def declare_cython_extension(ext_name, libraries=None): with open(core_path, "w") as f: f.writelines(content) -ext_modules = cythonize(ext_modules, - compiler_directives={'linetrace': True}) +ext_modules = cythonize(ext_modules) # =========== Package metadata =========== @@ -173,7 +172,7 @@ def declare_cython_extension(ext_name, libraries=None): install = setup( name = "pymarketcap", - version = "3.9.142", + version = "3.9.144", url = "https://github.com/mondeja/pymarketcap", download_url = "https://github.com/mondeja/pymarketcap/archive/master.zip", author = author, diff --git a/tests/conftest.py b/tests/conftest.py index 1eb989fc..af57d39c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,13 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import os +import sys import asyncio import pytest +sys.path.append(os.path.join(os.getcwd(), "pymarketcap")) + def pytest_addoption(parser): parser.addoption("--end2end", action="store_true", default=False, help="Run slower tests.") @@ -24,3 +28,4 @@ def event_loop(): #loop.close() pass + diff --git a/tests/test_sync_core/test_public_api/test_ticker.py b/tests/test_sync_core/test_public_api/test_ticker.py index 0d515787..65290310 100644 --- a/tests/test_sync_core/test_public_api/test_ticker.py +++ b/tests/test_sync_core/test_public_api/test_ticker.py @@ -37,7 +37,7 @@ def assert_types(res): if key in map_types: type_test(map_types, key, value) else: - assert isinstance(value, (float, type(None))) + assert isinstance(value, (float, int, type(None))) def test_consistence():