diff --git a/.travis.yml b/.travis.yml index 23ed648..4344ecb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,14 @@ sudo: false python: - 2.6 - 2.7 - - 3.3 - 3.4 - 3.5 - - "3.5-dev" + - 3.6 - "nightly" - pypy matrix: allow_failures: - python: 2.6 - - python: "3.5-dev" - python: "nightly" - python: pypy branches: diff --git a/README.rst b/README.rst index 56d961d..7680909 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,8 @@ PyBankID :alt: Documentation Status .. image:: http://img.shields.io/pypi/v/pybankid.svg :target: https://pypi.python.org/pypi/pybankid/ +.. image:: http://img.shields.io/pypi/dm/pybankid.svg + :target: https://pypi.python.org/pypi/pybankid/ .. image:: http://img.shields.io/pypi/l/pybankid.svg :target: https://pypi.python.org/pypi/pybankid/ .. image:: https://coveralls.io/repos/github/hbldh/pybankid/badge.svg?branch=master @@ -36,8 +38,8 @@ PyBankID can be installed though pip: pip install pybankid -To remedy the ``InsecurePlatformWarning`` problem detailed below -(`Python 2, urllib3 and certificate verification`_), you can install +The remedy the ``InsecurePlatformWarning`` problem detailed below ( +`Python 2, urllib3 and certificate verification`_), you can install ``pybankid`` with the ``security`` extras: .. code-block:: bash diff --git a/bankid/__init__.py b/bankid/__init__.py index 695d7ce..bfd0de6 100644 --- a/bankid/__init__.py +++ b/bankid/__init__.py @@ -1,69 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -"""Release data for the PyBankID project.""" -# A quick and dirty fix for installation and importing. -try: - from .client import BankIDClient - import bankid.exceptions as exceptions - from .certutils import create_bankid_test_server_cert_and_key +from .client import BankIDClient +import bankid.exceptions as exceptions +from .certutils import create_bankid_test_server_cert_and_key - __all__ = ['BankIDClient', 'exceptions', 'create_bankid_test_server_cert_and_key', 'version'] -except ImportError: - pass - -# Name of the package for release purposes. This is the name which labels -# the tarballs and RPMs made by distutils, so it's best to lowercase it. -_name = 'pybankid' - -# Version information. An empty _version_extra corresponds to a full -# release. 'dev' as a _version_extra string means this is a development -# version. -_version_major = 0 -_version_minor = 3 -_version_patch = 6 -# _version_extra = 'dev1' -# _version_extra = 'a1' -_version_extra = '' # Uncomment this for full releases - -# Construct full version string from these. -_ver = [_version_major, _version_minor, _version_patch] - -__version__ = '.'.join(map(str, _ver)) -if _version_extra: - __version__ = __version__ + '.' + str(_version_extra) - -version = __version__ # backwards compatibility name -version_info = (_version_major, _version_minor, _version_patch, _version_extra) - -__description__ = "BankID client for Python" - -__license__ = 'MIT' - -__authors__ = { - 'hbldh': ('Henrik Blidh', 'henrik.blidh@nedomkull.com'), -} -__author__ = 'Henrik Blidh' -__author_email__ = 'henrik.blidh@nedomkull.com' -__url__ = 'https://github.com/hbldh/pybankid/' -__download_url__ = 'https://github.com/hbldh/pybankid/tarball/' + '.'.join(map(str, _ver)) - -__platforms__ = ['Linux', 'Mac OSX', 'Windows XP/Vista/7/8'] -__keywords__ = ['BankID', 'SOAP'] -__classifiers__ = [ - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'License :: OSI Approved :: MIT License', - 'Operating System :: POSIX :: Linux', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: MacOS :: MacOS X', - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Topic :: Security', - 'Topic :: Utilities', -] +__all__ = ['BankIDClient', 'exceptions', 'create_bankid_test_server_cert_and_key', 'version'] diff --git a/bankid/client.py b/bankid/client.py index 4171590..d1ca7da 100644 --- a/bankid/client.py +++ b/bankid/client.py @@ -163,9 +163,9 @@ def _dictify(self, doc): out = {} try: for k in doc: - k = six.text_type(k) + k = _to_unicode(k) if isinstance(doc[k], Text): - out[k] = six.text_type(doc[k], encoding='utf-8') + out[k] = _to_unicode(doc[k]) elif isinstance(doc[k], datetime.datetime): out[k] = doc[k] else: @@ -176,6 +176,15 @@ def _dictify(self, doc): return out +def _to_unicode(s): + if isinstance(s, Text): + return six.text_type(s.unescape()) + elif isinstance(s, six.text_type): + return s + elif isinstance(s, six.binary_type): + return s.decode('utf-8') + + class RequestsTransport(HttpAuthenticated): """A Requests-based transport for suds, enabling the use of https and certificates when communicating with the SOAP service. diff --git a/bankid/version.py b/bankid/version.py new file mode 100644 index 0000000..fc5216d --- /dev/null +++ b/bankid/version.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +version.py +----------- + +:copyright: 2016-11-28 by hbldh + +""" + +from __future__ import division +from __future__ import print_function +from __future__ import absolute_import + +__version__ = '0.4.0' +version = __version__ # backwards compatibility name diff --git a/requirements.txt b/requirements.txt index 535e5ee..9018577 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -requests>=2.7.0 +requests>=2.13.0 suds-jurko>=0.6 -six>=1.9.0 +six>=1.10.0 diff --git a/setup.py b/setup.py index c9076dc..e221351 100644 --- a/setup.py +++ b/setup.py @@ -22,36 +22,51 @@ from __future__ import print_function from __future__ import absolute_import -import os +import re +from codecs import open from setuptools import setup, find_packages -import bankid -# Get the long description from the README file -try: - with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst')) as f: - long_description = f.read() -except: - long_description = __doc__ + +with open('bankid/version.py', 'r') as fd: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + + +def read(f): + return open(f, encoding='utf-8').read() setup( name='pybankid', - version=bankid.__version__, - author=bankid.__author__, - author_email=bankid.__author_email__, - description=bankid.__description__, - long_description=long_description, - license=bankid.__license__, - url=bankid.__url__, - classifiers=bankid.__classifiers__, - platforms=bankid.__platforms__, + version=version, + author='Henrik Blidh', + author_email='henrik.blidh@nedomkull.com', + description="BankID client for Python", + long_description=read('README.rst'), + license='MIT', + url='https://github.com/hbldh/pybankid/', + classifiers=[ + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX :: Linux', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: MacOS :: MacOS X', + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Topic :: Security', + 'Topic :: Utilities', + ], + platforms=['Linux', 'Mac OSX', 'Windows XP/Vista/7/8'], packages=find_packages(exclude=('tests', )), package_data={'': ['*.pem']}, - install_requires=[ - 'requests>=2.7.0', - 'suds-jurko>=0.6', - 'six>=1.9.0' - ], + install_requires=read('requirements.txt').strip().splitlines(), dependency_links=[], ext_modules=[], extras_require={