Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
#32 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
travis-ci committed Mar 18, 2018
1 parent d4b79b3 commit 786d1dd
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 33 deletions.
3 changes: 1 addition & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- "if %PYTHON%==C:\\Python36-x64 (%PYTHON%\\python -m pytest pymarketcap/tests -vs --end2end) else (%PYTHON%\\python -m pytest pymarketcap/tests -vs)"
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pymarketcap
`coinmarketcap <http://coinmarketcap.com/>`__ 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
-------
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pytest>=3.4.0
tox>=3.0.0rc1
tqdm>=4.19.5
tabulate>=0.8.2
sphinx>=1.7.0
Expand Down
2 changes: 1 addition & 1 deletion pymarketcap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mondejar1994@gmail.com>"
__repo__ = "https://github.com/mondeja/pymarketcap"
Expand Down
36 changes: 18 additions & 18 deletions pymarketcap/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -347,23 +350,22 @@ 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):
response[i]["symbol"] = str(response[i]["symbol"])
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
Expand Down Expand Up @@ -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):
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion pymarketcap/curl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===========
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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.")
Expand All @@ -24,3 +28,4 @@ def event_loop():
#loop.close()
pass


2 changes: 1 addition & 1 deletion tests/test_sync_core/test_public_api/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 786d1dd

Please sign in to comment.