{ "info": { "author": "Darius BERNARD", "author_email": "darius@yupeek.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "=================\nnameko-serializer\n=================\n\nenhenced json serializer for nameko micro-services.\n\n1. it allow to pass ``datetime.date`` and ``datetime.datetime`` to rpc calls and event arguments.\n get ride of ``datetime.datetime not JSON serializable`` errors messages in nameko.\n\n2. add support for namedtuple in service transmissions. you return a namedtuple instance,\n you get the same namedtuple in the other side, which is retro-comatible and support either ``res.attr`` or ``res['attr']``\n\nStable branch\n\n.. image:: https://img.shields.io/travis/Yupeek/nameko-serializer/master.svg\n :target: https://travis-ci.org/Yupeek/nameko-serializer\n\n.. image:: https://readthedocs.org/projects/nameko-serializer/badge/?version=latest\n :target: http://nameko-serializer.readthedocs.org/en/latest/\n\n.. image:: https://coveralls.io/repos/github/Yupeek/nameko-serializer/badge.svg?branch=master\n :target: https://coveralls.io/github/Yupeek/nameko-serializer?branch=master\n\n.. image:: https://img.shields.io/pypi/v/nameko-serializer.svg\n :target: https://pypi.python.org/pypi/nameko-serializer\n :alt: Latest PyPI version\n\n.. image:: https://requires.io/github/Yupeek/nameko-serializer/requirements.svg?branch=master\n :target: https://requires.io/github/Yupeek/nameko-serializer/requirements/?branch=master\n :alt: Requirements Status\n\nDevelopment status\n\n.. image:: https://img.shields.io/travis/Yupeek/nameko-serializer/develop.svg\n :target: https://travis-ci.org/Yupeek/nameko-serializer\n\n.. image:: https://coveralls.io/repos/github/Yupeek/nameko-serializer/badge.svg?branch=develop\n :target: https://coveralls.io/github/Yupeek/nameko-serializer?branch=develop\n\n.. image:: https://requires.io/github/Yupeek/nameko-serializer/requirements.svg?branch=develop\n :target: https://requires.io/github/Yupeek/nameko-serializer/requirements/?branch=develop\n :alt: Requirements Status\n\n\nInstallation\n------------\n\n1. Install using pip:\n\n ``pip install nameko-serializers``\n\n2. Alternatively, you can download or clone this repo and install with :\n\n ``pip install -e .``.\n\nRequirements\n------------\n\nwork with nameko up to 1.12.*\n\n\nExamples\n--------\n\n1. install: ``pip install nameko-serializers``\n2. configure: add in your config.yaml the folowing line: ``serializer: nameko-serializer``\n3. enjoy\n\ndatetime support (with timezone)\n\n.. code-block::python\n\n class MyService2:\n\n name = \"myservice2\"\n\n def compute_date(self, date):\n return date + datetime.timedelta(days=1)\n\n\n.. code-block::python\n\n MyNamedTuple = namedtuple('MyNamedTuple', ('arg1', 'arg2', 'date', 'datetime'))\n\n class MyService2:\n\n name = \"myservice2\"\n\n @rpc\n def compute_date(self, data: MyNamedTuple):\n return data.arg1 + data['arg2']\n\n\nDocumentation\n-------------\n\nthis Readme is currently the full documentation. it's not a library this big...\n\nfeatures\n--------\n\ndate and datetime serializing\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nthis serializer will handle datetime and date serializing. if a datetime is timezone naive, it will be made aware using\nthe detected current timezone (via ``tzlocal.get_localzone()``)\n\nall received dates will be timezone aware, but the timezone will be fixed to UTC.\n\nNamedTulpe support\n^^^^^^^^^^^^^^^^^^\n\nthis serializer allow to transmit namedtuple as dict, and will deserialize it as special namedtuple, supporting dict index\n\n.. code-block::python\n\n\t# python < 3.6: use collections.namedtuple\n\tfrom collections import namedtuple\n\n\tMyStruct = namedtuple('MyStruct', ('arg1', 'arg2', 'date', 'datetime'))\n\n\t# python >= 3.6: use NamedTulpe from typing, for a better type hinting\n\tfrom typing import NamedTuple, Optional\n\n\tclass MyStruct(NamedTuple):\n\t\targ1: int\n\t\targ2: int\n\t\tdate: datetime.date\n\t\tdatetime: Optional[datetime.datetime] = None\n\n\n\t# service with rich type hinting\n\tclass A:\n\t\tname = 'a'\n\n\t\t@rpc\n\t\tdef method(self, struct: MyStruct) -> MyStruct:\n\t\t\targ1, arg2, date, dt = struct\n\t\t\tassert arg1 + arg2 == struct.arg1 + struct['arg2']\n\t\t\tassert arg1 == struct[0] # safe only with python3.7+\n\t\t\treturn MyStruct(arg1=date.year)\n\n\n\n\n\nRequirements\n------------\n\n- Python 2.7, 3.6, 3.7\n\n.. note::\n\n this serializer use the builtin ordered dict feature to unserialize namedtuple with correct attributes order.\n if you use python2.7 or 3.6 without cPython, you must exclusively use argument's names and not indice.\n\n\n.. code-block::python\n\n MyNamedTuple = namedtuple('SpecialStruct', ('arg1', 'arg2'))\n\n @rpc\n def myfunc(self, special_struct):\n use_special_struct(*special_struct) # wrong in python < 3.7, since order is not garanteed\n use_special_struct(special_struct.arg1, special_struct.arg2) # good in any version\n\n\nContributions and pull requests are welcome.\n\n\nBugs and requests\n-----------------\n\nIf you found a bug or if you have a request for additional feature, please use the issue tracker on GitHub.\n\nhttps://github.com/Yupeek/nameko-serializer/issues\n\n\nknown limitations\n-----------------\n\n- if you pass some objects with keys ``__type__``, it will be converted.\n- all unserialized dates will be tz aware, and tzinfo will be set to UTC. (this is a good practice to change tz at display time)\n- for python < 3.7, the order in the namedtuple is not garanteed, use exclusively kwargs and attrs by names\n\nLicense\n-------\n\nYou can use this under GPLv3.\n\nAuthor\n------\n\nOriginal author: `Darius BERNARD `_.\n\n\nThanks\n------\n\nThanks to Nameko for this amazing framework.\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Yupeek/nameko-serializer", "keywords": "nameko json serializer namedtuple datetime", "license": "GPL3", "maintainer": "", "maintainer_email": "", "name": "nameko-serializer", "package_url": "https://pypi.org/project/nameko-serializer/", "platform": "", "project_url": "https://pypi.org/project/nameko-serializer/", "project_urls": { "Homepage": "https://github.com/Yupeek/nameko-serializer" }, "release_url": "https://pypi.org/project/nameko-serializer/1.0.0/", "requires_dist": [ "tzlocal", "pytz" ], "requires_python": "", "summary": "nameko serializer compatible with datetime and namedtuple", "version": "1.0.0" }, "last_serial": 5430669, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b6e2af949d68a430a28c455d1843a976", "sha256": "97e18c3e810afd27bb8ad171b1384d20f19e3910a8fc5a51f2f26754761869a7" }, "downloads": -1, "filename": "nameko_serializer-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b6e2af949d68a430a28c455d1843a976", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6629, "upload_time": "2019-06-21T12:51:46", "url": "https://files.pythonhosted.org/packages/57/18/011dbf884a85cf4c983c5615889767b484de19439e031f0c99bd95c170db/nameko_serializer-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c812139564b7f224fa28066ae8cf63a9", "sha256": "2f3cda106792f3706212a3ad119fe75234910aeb9498c11eee1a79bc8802f23f" }, "downloads": -1, "filename": "nameko-serializer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c812139564b7f224fa28066ae8cf63a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7308, "upload_time": "2019-06-21T12:51:49", "url": "https://files.pythonhosted.org/packages/2f/1d/12151b2811940c7093f9e222b574c93928491fb2358dd50de5bfaf0cf77c/nameko-serializer-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b6e2af949d68a430a28c455d1843a976", "sha256": "97e18c3e810afd27bb8ad171b1384d20f19e3910a8fc5a51f2f26754761869a7" }, "downloads": -1, "filename": "nameko_serializer-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b6e2af949d68a430a28c455d1843a976", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6629, "upload_time": "2019-06-21T12:51:46", "url": "https://files.pythonhosted.org/packages/57/18/011dbf884a85cf4c983c5615889767b484de19439e031f0c99bd95c170db/nameko_serializer-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c812139564b7f224fa28066ae8cf63a9", "sha256": "2f3cda106792f3706212a3ad119fe75234910aeb9498c11eee1a79bc8802f23f" }, "downloads": -1, "filename": "nameko-serializer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c812139564b7f224fa28066ae8cf63a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7308, "upload_time": "2019-06-21T12:51:49", "url": "https://files.pythonhosted.org/packages/2f/1d/12151b2811940c7093f9e222b574c93928491fb2358dd50de5bfaf0cf77c/nameko-serializer-1.0.0.tar.gz" } ] }