{ "info": { "author": "Skimlinks", "author_email": "dev@skimlinks.com", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://secure.travis-ci.org/skimhub/pyToXml.png?branch=master)](http://travis-ci.org/skimhub/pyToXml)\n\n# Synopsis\n\n from pytoxml import PyToXml\n\n person_details = {\n \"name\": \"Bob\",\n \"occupation\": \"Builder\",\n \"arrests\": [\n \"Assault / Battery\",\n \"Indecent Exposure\"\n ]\n }\n\n p2x = PyToXml(\"doc\", person_details)\n print p2x.encode()\n\nYields:\n\n \n \n Assault / Battery\n Indecent Exposure\n \n Bob\n Builder\n \n\n# Introduction\n\npytoxml gives you a simple way of converting a python structure to\nXML.\n\n# Tests\n\nRun the test suite with `py.test` (`pip install pytest`) from the root\nof the project.\n\n# Pluralisation of lists\n\nBy default pytoxml will use the element name `item` which is probably\nnot what you want. Here's a simple example of how you might use a map\nto determine the best phrase for a list element:\n\n class BetterListsDemo(PyToXml):\n def pluralisation(self, plural):\n pluralisation_map = {\n \"arrests\": \"arrest\"\n }\n\n return pluralisation_map.get(plural) or \"item\"\n\n p2x = BetterListsDemo(\"doc\", person_details)\n print p2x.encode()\n\nWhich gives:\n\n \n \n Assault / Battery\n Indecent Exposure\n \n Bob\n Builder\n \n\nThe `pluralisation` function takes `plural` as an argument which is\nthe name of the direct parent element to the one you'll be creating.\n\n# Custom Handlers\n\nBy default pytoxml will only encode a few types, if you want to\nencode, for example, exceptions, you might do the following:\n\n def temp_convertor(structure, element, name):\n element.text = str(structure)\n\n p2x = PyToXml(\"a\", { \"b\": Exception(\"Should now serialise\") })\n p2x.add_type_handler(Exception, temp_convertor)\n self.assertEqual(str(p2x.encode()), \"Should now serialise\")\n\nIf you give an object a `__pytoxml__` method then you don't need to\nregister a handler:\n\n class MyException(Exception):\n def __pytoxml__(self, structure, element, name):\n element.text = str(self)\n\n p2x = PyToXml(\"a\", { \"b\": MyException(\"Should now serialise\") })\n self.assertEqual(str(p2x.encode()), \"Should now serialise\")\n\n# CData and attributes\n\nThough it's somewhat orthogonal to the original justification of\nPyToXml, you can easily output CDATA elements and attributes:\n\n from pytoxml import PyToXml\n\n cdata = pytoxml.CData(\"xml\")\n attributes = pytoxml.Attributes(\"simple text\", {\"one\": \"two\"})\n\n p2x = pytoxml.PyToXml(\"root\", { \"raw\": cdata, \"attributed\": attributes })\n p2x.encode()\n\ngives (un-formatted):\n\n \n \n xml]]>\n simple text\n \n\n# Constructor Options\n\n## xml_declaration\n\nOutput the XML declaration. Defaults to `False`.\n\n p2x = PyToXml(\"doc\", \"hello\", encoding=\"latin1\", xml_declaration=True)\n print p2x.encode()\n\nYields:\n\n \n hello\n\n## encoding\n\n# Attributes on the root element\n\n p2x = PyToXml(\"a\", { }, root_attributes={\"one\": \"two\"} )\n p2x.encode()\n\ngives:\n\n \n\nWhich encoding system should be used to build Defaults to `UTF-8`.\n\n# Licence\n\nCopyright (C) 2012-2014 Skimbit LTD.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "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/skimhub/pyToXml", "keywords": "python skimlinks xml dict array", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pyToXml", "package_url": "https://pypi.org/project/pyToXml/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyToXml/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/skimhub/pyToXml" }, "release_url": "https://pypi.org/project/pyToXml/1.1.0/", "requires_dist": null, "requires_python": null, "summary": "Simple Python to XML library.", "version": "1.1.0" }, "last_serial": 968744, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ba674184ca8bfe21b66540e470d2c138", "sha256": "1c5d87bce88754ac22d3934580f17d0289bd5df9fb25662de1c085593ff8ad74" }, "downloads": -1, "filename": "pyToXml-0.1-py2.7.egg", "has_sig": false, "md5_digest": "ba674184ca8bfe21b66540e470d2c138", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 4513, "upload_time": "2012-03-22T18:01:39", "url": "https://files.pythonhosted.org/packages/b1/02/1d6b5ceb6576823fe812528bc7f137bcf61a9db9d4921b7ff64f12f0152c/pyToXml-0.1-py2.7.egg" } ], "0.2": [ { "comment_text": "built for Linux-3.0.0-14-generic-x86_64-with-glibc2.4", "digests": { "md5": "bbdc421a3a79fc3c8b8da2fdd2db1414", "sha256": "e2e10de6ff9f30b895fb8031b5524a36ad1cbd64337fd4363af29e0d0545873b" }, "downloads": -1, "filename": "pyToXml-0.2.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "bbdc421a3a79fc3c8b8da2fdd2db1414", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 3915, "upload_time": "2012-03-23T18:08:17", "url": "https://files.pythonhosted.org/packages/ea/a9/cf9a0d3bf796879e06efed42b549e07b5746135a7a7ca1a8786c379fc149/pyToXml-0.2.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "e0301b6592c6da1246643e0e68d3925c", "sha256": "4792f7f2bd49db0c864126b995c6244c3322c01292227955480a648f17fe4fd7" }, "downloads": -1, "filename": "pyToXml-0.2-py2.7.egg", "has_sig": false, "md5_digest": "e0301b6592c6da1246643e0e68d3925c", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 4516, "upload_time": "2012-03-22T18:04:02", "url": "https://files.pythonhosted.org/packages/50/3d/49ddeb548fb136614683933e8c392238d8685e5171e9ae5de0fa5978e196/pyToXml-0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "5e643edcb9690c728bedb919ab4574b5", "sha256": "110442bccc18481445465ad02df1f9222e976d811ad2da87c0c994dd6b61e930" }, "downloads": -1, "filename": "pyToXml-0.2.tar.gz", "has_sig": false, "md5_digest": "5e643edcb9690c728bedb919ab4574b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3791, "upload_time": "2012-03-23T18:20:15", "url": "https://files.pythonhosted.org/packages/1e/df/7b72bd39473c01adab64492609eb39344b80ca072214f1ae96810909f228/pyToXml-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "82133120e239dff4406d45b18eaac5ef", "sha256": "f4e4390068335982dce1906f92d96a5fa1efe7c718693ed10861460869528e55" }, "downloads": -1, "filename": "pyToXml-0.3.tar.gz", "has_sig": false, "md5_digest": "82133120e239dff4406d45b18eaac5ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3787, "upload_time": "2012-03-23T18:22:36", "url": "https://files.pythonhosted.org/packages/c8/1b/d23517d08792d4ec6bf29e7a92b0114bf5c2dbf39b1fc7c7a846fe568d59/pyToXml-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "ae70574f6366a20a9e311944b380c54e", "sha256": "1ab9e64b08204f9641b0e5bb0dc8f86b3a2dc27f0771aab3f462700983c174b0" }, "downloads": -1, "filename": "pyToXml-0.4.tar.gz", "has_sig": false, "md5_digest": "ae70574f6366a20a9e311944b380c54e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4149, "upload_time": "2012-03-23T18:24:50", "url": "https://files.pythonhosted.org/packages/0b/af/18c9fe144e12062bdc69942bd5d8de8b23efb8ee97405506d626c2ccc0ff/pyToXml-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "93efcd3c5b623df374346c666f962b7d", "sha256": "57cdb6cfaa990fbb6f36321b84003e3fe4f31cd2d05691a6df8643dc2fb3290a" }, "downloads": -1, "filename": "pyToXml-0.5.tar.gz", "has_sig": false, "md5_digest": "93efcd3c5b623df374346c666f962b7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4239, "upload_time": "2012-03-23T18:39:34", "url": "https://files.pythonhosted.org/packages/5c/8f/01d9859374fe18448c440a0df0a7b736ef40dd9c6807d8cbb0a551d7e0a4/pyToXml-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "aac82972232e4829b144d1cbd7a559c6", "sha256": "bce0353a0dad75cc901d9d0a600dd2b73dca85aca5c25239ff53f371070e9e82" }, "downloads": -1, "filename": "pyToXml-0.6.tar.gz", "has_sig": false, "md5_digest": "aac82972232e4829b144d1cbd7a559c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4348, "upload_time": "2012-03-30T14:25:09", "url": "https://files.pythonhosted.org/packages/35/9f/79a2225ca55406ed348e22a0571d399cc7c656a706e73efd9ed047a2fe68/pyToXml-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "40afcd6a29e9d1ba1194377b7db87846", "sha256": "c1f8d5f596d0f1cf5f999a5b234f9dcb25f94ddd6552bd7d3465282d12e33ba2" }, "downloads": -1, "filename": "pyToXml-0.7.tar.gz", "has_sig": false, "md5_digest": "40afcd6a29e9d1ba1194377b7db87846", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5162, "upload_time": "2012-06-25T12:33:12", "url": "https://files.pythonhosted.org/packages/71/ce/010464b9858ed90f14889ce4a7ebe9bb130cddde1de6c584647827ce5cd5/pyToXml-0.7.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "44555000a68f332bc9816269791ab3c8", "sha256": "7863e573aa0904c5fce5084ee48cfbd2784647c0a49896d1772e04e3252b4bcf" }, "downloads": -1, "filename": "pyToXml-0.9.tar.gz", "has_sig": false, "md5_digest": "44555000a68f332bc9816269791ab3c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5552, "upload_time": "2012-06-25T15:15:53", "url": "https://files.pythonhosted.org/packages/a4/cf/0961e4a150f13803a1f7aabd5f60363a5fa5108f2f13e50dffb60881b2ab/pyToXml-0.9.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "61ccbad176ab0b7db9001b77fae0590c", "sha256": "27e9c3241ce530b94aad04ea0bc5ade776da3abe0ac5c5df288404e1855bb095" }, "downloads": -1, "filename": "pyToXml-1.0.0.tar.gz", "has_sig": false, "md5_digest": "61ccbad176ab0b7db9001b77fae0590c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5640, "upload_time": "2012-07-02T17:27:07", "url": "https://files.pythonhosted.org/packages/d1/0e/79e470c7fdf02f9d932656828973c784f57bb4747a6c47273415a4350c48/pyToXml-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "bf8bf050d5458eb8e0716fa29d785730", "sha256": "b669e430d2da29c4f4516fc061cb30eb67cc2a65c861b0689213757514494d09" }, "downloads": -1, "filename": "pyToXml-1.1.0.tar.gz", "has_sig": false, "md5_digest": "bf8bf050d5458eb8e0716fa29d785730", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6163, "upload_time": "2014-01-14T12:33:51", "url": "https://files.pythonhosted.org/packages/e9/5b/4616102ac6f3fff0d2e2740dfc8702ca5c211f9092fb8c6b86f5801f94b4/pyToXml-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bf8bf050d5458eb8e0716fa29d785730", "sha256": "b669e430d2da29c4f4516fc061cb30eb67cc2a65c861b0689213757514494d09" }, "downloads": -1, "filename": "pyToXml-1.1.0.tar.gz", "has_sig": false, "md5_digest": "bf8bf050d5458eb8e0716fa29d785730", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6163, "upload_time": "2014-01-14T12:33:51", "url": "https://files.pythonhosted.org/packages/e9/5b/4616102ac6f3fff0d2e2740dfc8702ca5c211f9092fb8c6b86f5801f94b4/pyToXml-1.1.0.tar.gz" } ] }