diff --git a/docs/changelog.rst b/docs/changelog.rst index 3c0ccd8d..46670ec5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,7 @@ Version 1.0.0 + 将图文消息单个消息的渲染函数放到 :class:`werobot.replies.Article` 内 + 取消对 Python2.6, Python3.3 的支持 + 增加与 Django 1.6+, Flask, Bottle, Tornado 集成的支持 ++ 替换 `inspect.getargspec()` Version 0.6.1 ---------------- diff --git a/requirements.txt b/requirements.txt index 1fd300b2..f9ee0374 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ bottle requests six -xmltodict +xmltodict \ No newline at end of file diff --git a/setup.py b/setup.py index 7972a8bc..eb630007 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import io import werobot +import platform from setuptools import setup, find_packages @@ -10,6 +11,11 @@ readme = f.read().replace("develop", "master") readme = readme.replace("latest", werobot.__version__) +version = platform.python_version_tuple() +install_requires = open("requirements.txt").readlines() +if version < ('3', '3'): + install_requires.append('funcsigs') + setup( name='WeRoBot', version=werobot.__version__, @@ -23,7 +29,7 @@ setup_requires=[ 'pytest-runner', ], - install_requires=open("requirements.txt").readlines(), + install_requires=install_requires, include_package_data=True, license='MIT License', classifiers=[ diff --git a/travis/script.sh b/travis/script.sh index 1d77dd4f..3aa3d3b5 100644 --- a/travis/script.sh +++ b/travis/script.sh @@ -3,5 +3,6 @@ if [ $PYTHON_INSTALL_METHOD == "tox" ]; then env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" tox else + python setup.py install coverage run --source werobot -m py.test fi \ No newline at end of file diff --git a/werobot/robot.py b/werobot/robot.py index 55490811..0cd1da4c 100644 --- a/werobot/robot.py +++ b/werobot/robot.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals import six -import inspect import werobot @@ -12,6 +11,11 @@ from werobot.replies import process_function_reply from werobot.utils import to_binary, to_text, check_signature +try: + from inspect import signature +except ImportError: + from funcsigs import signature + __all__ = ['BaseRoBot', 'WeRoBot'] _DEFAULT_CONFIG = dict( @@ -189,7 +193,7 @@ def key_click(self, key): """ def wraps(f): - argc = len(inspect.getargspec(f).args) + argc = len(signature(f).parameters.keys()) @self.click def onclick(message, session=None): @@ -234,7 +238,7 @@ def wraps(f): for x in args: self.filter(x)(f) return f - argc = len(inspect.getargspec(f).args) + argc = len(signature(f).parameters.keys()) @self.text def _f(message, session=None): @@ -252,7 +256,7 @@ def add_handler(self, func, type='all'): if not callable(func): raise ValueError("{} is not callable".format(func)) - self._handlers[type].append((func, len(inspect.getargspec(func).args))) + self._handlers[type].append((func, len(signature(func).parameters.keys()))) def get_handlers(self, type): return self._handlers.get(type, []) + self._handlers['all']