{ "info": { "author": "Hong Minhee", "author_email": "hongminhee@member.fsf.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: Jython", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: Stackless" ], "description": "TypeQuery\n=========\n\n.. note::\n\n Since Python 3.3 there's ``functools.singledispatch()`` function\n which does the similar work in the standard library. We recommend\n you to use it instead of this.\n\n See also `PEP 443`_.\n\n.. image:: https://drone.io/bitbucket.org/dahlia/typequery/status.png\n :alt: Build Status\n :target: https://drone.io/bitbucket.org/dahlia/typequery/latest\n\nIt provides a simple and dirty way to define generic methods to existing\ntypes. You can make overloaded methods using this.\n\n.. _PEP 443: http://www.python.org/dev/peps/pep-0443/\n\n\nCompatibility\n-------------\n\nTypeQuery does not depend on any non-standard libraries. It works on\nthese environments:\n\n- Python 2.5--2.7, 3.2--3.5\n- CPython, Stackless, PyPy, Jython\n\n\nInstall\n-------\n\nInstall using ``pip``::\n\n $ pip install TypeQuery\n\n\nExample: JSON encoder\n---------------------\n\n::\n\n from typequery import GenericMethod\n from sys import version_info\n from re import sub\n from numbers import Real\n from collections import Mapping, Iterable\n\n if version_info.major > 2:\n basestring = string = str\n else:\n string = unicode\n\n json = GenericMethod('json')\n\n @json.of(type(None))\n def json(value):\n return 'null'\n\n @json.of(bool)\n def json(value):\n return 'true' if value else 'false'\n\n @json.of(Real)\n def json(value):\n return str(value)\n\n @json.of(string)\n def json(value):\n def escape(match):\n s = match.group(0)\n if s in ('\\\\', '\"', '\\b', '\\f', '\\n', '\\r', '\\t'):\n return '\\\\' + s\n n = ord(s)\n if n < 0x10000:\n return r'\\u%04x' % n\n n -= 0x10000\n s1 = 0xd800 | ((n >> 10) & 0x3ff)\n s2 = 0xdc00 | (n & 0x3ff)\n return r'\\u%04x\\u%04x' % (s1, s2)\n return '\"%s\"' % sub(r'([\\\\\"]|[^\\ -~])', escape, value)\n\n @json.of(Iterable)\n def json(value):\n return '[%s]' % ', '.join(json(element) for element in value)\n\n @json.of(Mapping)\n def json(value):\n return '{%s}' % ', '.join('%s: %s' % (json(string(key)), json(value))\n for key, value in value.items())\n\nAnd defined ``json`` function works like:\n\n>>> json(123)\n'123'\n>>> json(True)\n'true'\n>>> json({'apple': 3, 'banana': 5, 'carrot': 1})\n'{\"apple\": 3, \"banana\": 5, \"carrot\": 1}'\n\nAs the above shows, you can define type-aware instance methods to existing\ntypes even including ABCs like ``collections.Iterable``.\n\n\nAuthor and license\n------------------\n\nWritten by `Hong Minhee `_. Distributed under `MIT license\n`_. You can find the source code from the\n`Bitbucket repository `_::\n\n $ hg clone https://bitbucket.org/dahlia/typequery\n\n\nChangelog\n---------\n\nVersion 0.1.5\n'''''''''''''\n\nReleased on June 23, 2016.\n\n- Compatibility with recent Python versions: Python 3.3 to 3.5, and PyPy3.\n\n\nVersion 0.1.4\n'''''''''''''\n\nReleased on October 18, 2012.\n\n- Don't use bitbucket-distutils_ anymore to prevent several headaches\n related packaging and distribution.\n\n.. _bitbucket-distutils: https://bitbucket.org/dahlia/bitbucket-distutils\n\n\nVersion 0.1.3\n'''''''''''''\n\nReleased on August 29, 2012.\n\n- Fixed a bug of handling multiple types by one function.\n [`#2 `_]\n\n\nVersion 0.1.2\n'''''''''''''\n\nReleased on August 15, 2012.\n\n- You can inherit existing generic methods using ``GenericMethod.inherit()``\n method.\n- Added ``with_receiver`` option for ``GenericMethod.of()`` decorator and\n ``Decorator`` constructor.\n\n\nVersion 0.1.1\n'''''''''''''\n\nReleased on May 22, 2012.\n\n- Now it works well with abstract base classes other than ``abc.ABCMeta``.\n- Fixed a bug of ``GenericMethod.clone()`` method. It does not reflect\n cloned one's changes to the original anymore.\n [`#1 `_]\n\n\nVersion 0.1.0\n'''''''''''''\n\nReleased on May 21, 2012.\n\n- Initial release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/dahlia/typequery", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "TypeQuery", "package_url": "https://pypi.org/project/TypeQuery/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/TypeQuery/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/dahlia/typequery" }, "release_url": "https://pypi.org/project/TypeQuery/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "A simple and dirty way to define generic methods to existing types.", "version": "0.1.5" }, "last_serial": 2181760, "releases": { "0.1.0": [], "0.1.1": [], "0.1.2": [], "0.1.3": [], "0.1.4": [ { "comment_text": "", "digests": { "md5": "457d54c37a83e4b89164b9f2cdc89612", "sha256": "4dd59fdd91794efdd6c36b8473de5bfc1f6cbca4317576000eba7947c5891a66" }, "downloads": -1, "filename": "TypeQuery-0.1.4.tar.gz", "has_sig": false, "md5_digest": "457d54c37a83e4b89164b9f2cdc89612", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6778, "upload_time": "2012-10-18T13:21:44", "url": "https://files.pythonhosted.org/packages/88/45/54f01328552669f7c8df96234c394c0b14a7b933f31866fd10c078f07343/TypeQuery-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "287f1f57069cd1b81f28c4f6cacd3991", "sha256": "a8fc9642eff2e04eb705897c3361ccc6530cffc71ec222a54135e6dba28517d6" }, "downloads": -1, "filename": "TypeQuery-0.1.5-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "287f1f57069cd1b81f28c4f6cacd3991", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 9836, "upload_time": "2016-06-22T18:19:31", "url": "https://files.pythonhosted.org/packages/4a/89/c30bd30a30cc65c71dad3c54d85453173141856017c21f03dfa4ab0eeb25/TypeQuery-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8e1dbdc023c8fe4c01229f564a81ac0", "sha256": "00f60785053723bca1edb519264fb05c3becbe462ba157da47a90e7ae34fb9bd" }, "downloads": -1, "filename": "TypeQuery-0.1.5.tar.gz", "has_sig": true, "md5_digest": "a8e1dbdc023c8fe4c01229f564a81ac0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7098, "upload_time": "2016-06-22T18:19:26", "url": "https://files.pythonhosted.org/packages/ac/f9/7015735ceac509438f54a944fb0e17f7f429e39712ee6c7e01273dbd3a37/TypeQuery-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "287f1f57069cd1b81f28c4f6cacd3991", "sha256": "a8fc9642eff2e04eb705897c3361ccc6530cffc71ec222a54135e6dba28517d6" }, "downloads": -1, "filename": "TypeQuery-0.1.5-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "287f1f57069cd1b81f28c4f6cacd3991", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 9836, "upload_time": "2016-06-22T18:19:31", "url": "https://files.pythonhosted.org/packages/4a/89/c30bd30a30cc65c71dad3c54d85453173141856017c21f03dfa4ab0eeb25/TypeQuery-0.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8e1dbdc023c8fe4c01229f564a81ac0", "sha256": "00f60785053723bca1edb519264fb05c3becbe462ba157da47a90e7ae34fb9bd" }, "downloads": -1, "filename": "TypeQuery-0.1.5.tar.gz", "has_sig": true, "md5_digest": "a8e1dbdc023c8fe4c01229f564a81ac0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7098, "upload_time": "2016-06-22T18:19:26", "url": "https://files.pythonhosted.org/packages/ac/f9/7015735ceac509438f54a944fb0e17f7f429e39712ee6c7e01273dbd3a37/TypeQuery-0.1.5.tar.gz" } ] }