{ "info": { "author": "Gilles Devaux", "author_email": "gilles.devaux@gmail.com", "bugtrack_url": null, "classifiers": [], "description": ".. Voyeur documentation master file, created by\n sphinx-quickstart on Mon Feb 24 13:55:51 2014.\n You can adapt this file completely to your liking, but it should at least\n contain the root `toctree` directive.\n\nVoyeur\n======\n\n.. image:: https://api.travis-ci.org/gilles/voyeur.png?branch=master\n :target: https://api.travis-ci.org/gilles/voyeur\n\n\nVoyeur is an simple library to serialize an object into another object.\n\nThe goal is to create a representation that is easily `json.dumps()` friendly.\n\nI've made it while working with datastore such as Riak, MongoDB or CouchBase where the response is a dict and\nI wanted to transform it into another dict for API output.\n\nQuickstart\n----------\n\nIt's as easy as this:\n\n.. code-block:: python\n\n from voyeur import view\n\n definition = {\n 'id': int\n }\n\n data = {\n 'id': '1'\n }\n\n result = view(data, definition)\n assert result = {'id' : 1}\n\nThe definition is a dictionary with key/callable pairs. Voyeur will use the key to get the value from the data then apply the callable.\n\nUsing objects\n-------------\n\nThat works too:\n\n.. code-block:: python\n\n from voyeur import view\n\n definition = {\n 'id': int\n 'prop': int\n }\n\n class Data(object):\n id = 1\n\n @property\n def prop(self):\n return \"12\"\n\n result = view(Data(), definition)\n assert result = {'id' : 1, 'prop' : 12}\n\n\nUsing runtime parameters\n------------------------\n\nA callable can take any kwargs and use them\n\n.. code-block:: python\n\n from voyeur import view\n\n def mycallable(value, test=None):\n return \"foo:%s:%s\" % (value, test)\n\n definition = {\n 'id': int\n 'prop': mycallable\n }\n\n class Data(object):\n id = 1\n\n @property\n def prop(self):\n return \"12\"\n\n result = view(Data(), definition, test='bar')\n assert result = {'id' : 1, 'prop' : 'foo:12:bar'}\n\nMore complex types\n------------------\n\nVoyeur can take a class as a callable if it inherits from :py:class:`voyeur.types.Type`. This allows building more complex serializer.\n\nA good example is the :py:class:`voyeur.types.Type` that reads the value from a different field.\n\n.. code-block:: python\n\n from voyeur import view\n definition = {\n 'field': DeferredType('anotherfield', int),\n }\n\n data = {'anotherfield': '2'}\n result = view(data, definition)\n assert result == {'field':2}\n\n\nIndices and tables\n==================\n\n.. toctree::\n :maxdepth: 2\n\n api\n\n* :ref:`genindex`\n* :ref:`modindex`\n* :ref:`search`\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gilles/voyeur", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "voyeur", "package_url": "https://pypi.org/project/voyeur/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/voyeur/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/gilles/voyeur" }, "release_url": "https://pypi.org/project/voyeur/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Dead simple library for object serialization", "version": "0.1.1" }, "last_serial": 1015891, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e70125ff014f3f0e85db38312be48bf8", "sha256": "1e4b01390d4b927124d4688e19a9d7f37c54ee11bd4c7ea2238b9c1c9fb1b061" }, "downloads": -1, "filename": "voyeur-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e70125ff014f3f0e85db38312be48bf8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3350, "upload_time": "2014-02-25T00:05:49", "url": "https://files.pythonhosted.org/packages/4e/97/0b72c50dc8e236aa3b0c5f83e5fd957e65ea8218078d28ad2970f9e6f0b1/voyeur-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "c90afbba6ec9138a8c21799266004393", "sha256": "6dacded1f9ba1beb942c542399af4079196cfe9f931d3d952e5f79f9cddf08d7" }, "downloads": -1, "filename": "voyeur-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c90afbba6ec9138a8c21799266004393", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3618, "upload_time": "2014-03-01T19:09:30", "url": "https://files.pythonhosted.org/packages/0d/38/984bed084973d4055448760cb210926678d0f2b7d9473c72f17b4d259b32/voyeur-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c90afbba6ec9138a8c21799266004393", "sha256": "6dacded1f9ba1beb942c542399af4079196cfe9f931d3d952e5f79f9cddf08d7" }, "downloads": -1, "filename": "voyeur-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c90afbba6ec9138a8c21799266004393", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3618, "upload_time": "2014-03-01T19:09:30", "url": "https://files.pythonhosted.org/packages/0d/38/984bed084973d4055448760cb210926678d0f2b7d9473c72f17b4d259b32/voyeur-0.1.1.tar.gz" } ] }