{
"info": {
"author": "Michael Palumbo",
"author_email": "michael.palumbo87@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup :: XML",
"Topic :: Utilities"
],
"description": "=================================================\niXML - A simple iterative event-driven XML parser\n=================================================\n\n.. image:: https://secure.travis-ci.org/YAmikep/ixml.png\n :target: https://travis-ci.org/YAmikep/ixml\n\n.. image:: https://coveralls.io/repos/YAmikep/ixml/badge.png\n :target: https://coveralls.io/r/YAmikep/ixml \n\n.. image:: https://pypip.in/v/ixml/badge.png\n :target: https://crate.io/packages/ixml/\n\n.. image:: https://pypip.in/d/ixml/badge.png\n :target: https://crate.io/packages/ixml/\n\n\niXML is an iterative event-driven XML parser with a standard Python iterator interface.\n\n\n\nDocs\n----\n\n.. http://ixml.readthedocs.org/en/latest/\n\n\n\nInstall\n-------\n\nFrom PyPI (stable)::\n\n pip install ixml\n\nFrom Github (unstable)::\n\n pip install git+git://github.com/YAmikep/ixml.git#egg=ixml\n\n\niXML currently requires the `lxml `_ library because there is no fallback backend based on the standard library yet.\n\n\nMain API\n---------\n\n- ``ixml.parse(data)``: iterator returning parsing events.\n\n- ``ixml.items(data, path, builder_klass=DictObjectBuilder)``: iterator returning Python objects found under a specified path.\n\nNotes:\n\n- ``data`` must be a file like object.\n\n- The Python objects yielded by ``ixml.items`` are constructed from the parsing events by an ``ObjectBuilder`` (``DictObjectBuilder`` by default). Please make your own if you wish as long as it implements the ``ObjectBuilder`` interface (see ``ixml.builders.interface``).\n\n- Top-level ``ixml`` module tries to automatically find and import a suitable parsing backend. You can also explicitly import a required backend from ``ixml.backends``.\n\n\n\nUsage and examples\n------------------\n\nAll examples will be using this XML document:\n\n.. code:: python\n\n >>> XML = '''\n \n \n France\n French\n \n Eiffel Tower\n Triumphal Arch\n Louvre Museum\n Quai Branly Museum\n \n \n \n USA\n English\n \n Bank America Plaza\n Dallas Theatre Center\n Dallas Museum of Art\n Old Red Museum\n \n \n '''\n\n\n- **ixml.parse**\n\nUsing the ``parse`` function, you can react on individual events:\n\n.. code:: python\n\n >>> import ixml\n >>> from StringIO import StringIO\n \n # The parse function takes a file like object\n >>> data = StringIO(XML)\n\n # Extract only the languages and the countries\n >>> languages, countries = set(), set()\n >>> for path, event, value in ixml.parse(data):\n ... if path == 'cities.city.language':\n ... languages.add(value)\n ... elif path == 'cities.city.country':\n ... countries.add(value)\n >>> print languages, countries\n set(['French', 'English']) set(['USA', 'France'])\n\n\nBelow are all the parsing events from ``parse``:\n\n.. code:: python\n\n ('cities', u'start', None)\n ('cities.city', u'start', None)\n ('cities.city.@name', 'data', 'Paris')\n ('cities.city.country', 'data', 'France')\n ('cities.city.language', 'data', 'French')\n ('cities.city.attractions', u'start', None)\n ('cities.city.attractions.monument', 'data', 'Eiffel Tower')\n ('cities.city.attractions.monument', 'data', 'Triumphal Arch')\n ('cities.city.attractions.museum', 'data', 'Louvre Museum')\n ('cities.city.attractions.museum', 'data', 'Quai Branly Museum')\n ('cities.city.attractions', u'end', None)\n ('cities.city', u'end', None)\n ('cities.city', u'start', None)\n ('cities.city.@name', 'data', 'Dallas')\n ('cities.city.country', 'data', 'USA')\n ('cities.city.language', 'data', 'English')\n ('cities.city.attractions', u'start', None)\n ('cities.city.attractions.monument', 'data', 'Bank America Plaza')\n ('cities.city.attractions.monument', 'data', 'Dallas Theatre Center')\n ('cities.city.attractions.museum', 'data', 'Dallas Museum of Art')\n ('cities.city.attractions.museum', 'data', 'Old Red Museum')\n ('cities.city.attractions', u'end', None)\n ('cities.city', u'end', None)\n ('cities', u'end', None)\n\n\n- **ixml.items**\n\nAnother usage is having iXML yields native Python objects for a specific path with ``items``:\n\n.. code:: python\n\n >>> import ixml\n >>> from StringIO import StringIO\n \n # The items function takes a file like object\n >>> data = StringIO(XML)\n\n >>> for city in ixml.items(data, 'cities.city'):\n ... do_something_with(city)\n\n\nBelow are the two \"city\" Python objects created. They are constructed as a dict by default. \nYou can change this behavior by providing another builder class to the ``items`` function.\n\n.. code:: python\n\n { \n 'country': 'France', \n '@name': 'Paris', \n 'language': 'French', \n 'attractions': {\n 'museum': ['Louvre Museum', 'Quai Branly Museum'],\n 'monument': ['Eiffel Tower', 'Triumphal Arch']\n }\n }\n {\n 'country': 'USA',\n '@name': 'Dallas',\n 'language': 'English',\n 'attractions': {\n 'museum': ['Dallas Museum of Art', 'Old Red Museum'], \n 'monument': ['Bank America Plaza', 'Dallas Theatre Center']\n }\n }\n\n\n\nParsing events\n--------------\n\nParsing events contain the XML tree context (path), an event and a value::\n\n (path, event, value)\n\n\n1. **The tree context (or path)**\n\nIt is a simplified path format that:\n\n- uses dots to define different levels\n- uses namespace prefixes in the tag name\n- ignores default namespaces (handled automatically behind the scene)\n- uses @ for attributes\n\nExamples:\n\n- rss.channel.item\n- rss.channel.item.@myAttr\n- rss.channel.ns1:item.title\n\n\n2. **The events**\n\n- \"start\" and \"end\" for containers:\n\n.. code:: python\n\n # => ('rss', 'start', None)\n <...>\n # => ('rss', 'end', None)\n\n\n- \"data\" for leaves and attributes:\n\n.. code:: python\n\n \n Some text # => ('rss.title', 'data', 'Some text'), ('rss.title.@myAttr', 'data', 'Test')\n \n\n\n3. **The value**\n\nIf there is a value, it will always be a string, None otherwise.\nThere is currently no automatic conversion feature (to int, etc).\n\n\nBackends\n--------\n\niXML can provide several implementation of the parsing by using backends located in ixml/backends:\n\n- ``lxmliterparse``: wrapper around the well known `iterparse LXML `_ function.\n\nYou can import a specific backend and use it in the same way as the top level library:\n\n.. code:: python\n\n >>> import ixml.backends.lxmliterparse as ixml\n >>> for path, event, value in ixml.parse(...):\n ... # ... \n\nImporting the top level library as ``import ixml`` tries to import all backends in order.\n\niXML currently requires the `lxml `_ library because there is no fallback backend based on the standard library yet.\n\n\n\nObjectBuilder\n------------\nThe ``items`` function uses an ObjectBuilder to build an object while parsing the data.\n\nThe events are passed into the ``event`` function of the builder that accepts three parameters: path, event type and value.\nThe object being built is available at any time from the ``value`` attribute.\n\nYou can make your own builder as long as it implements the ObjectBuilder interface (see ixml/builders/interface).\n\n\n\nContribute\n----------\n\nClone and install testing dependencies::\n\n $ python setup.py develop \n $ pip install -r requirements_tests.txt\n\nEnsure tests pass::\n\n $ ./scripts/runtests.sh\n\nOr using tox::\n\n $ tox",
"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/YAmikep/ixml",
"keywords": null,
"license": "Copyright (C) 2013, Michael Palumbo\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.",
"maintainer": null,
"maintainer_email": null,
"name": "ixml",
"package_url": "https://pypi.org/project/ixml/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/ixml/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://bitbucket.org/YAmikep/ixml"
},
"release_url": "https://pypi.org/project/ixml/0.1.0/",
"requires_dist": null,
"requires_python": null,
"summary": "iXML is an iterative event-driven XML parser with a standard Python iterator interface.",
"version": "0.1.0"
},
"last_serial": 842170,
"releases": {
"0.1.0": [
{
"comment_text": "",
"digests": {
"md5": "fc48c3f7b8ed9d0aef47376a145289b5",
"sha256": "9e420b93ee5efb741545f61d5904fbe6f1fb723dafd07ace90bbea7232a9b7aa"
},
"downloads": -1,
"filename": "ixml-0.1.0.zip",
"has_sig": false,
"md5_digest": "fc48c3f7b8ed9d0aef47376a145289b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17645,
"upload_time": "2013-08-17T13:25:39",
"url": "https://files.pythonhosted.org/packages/a8/d5/216faa51321d92239ce6ad95781c7c9eb486c9b9c54acb3209c8026dc1a8/ixml-0.1.0.zip"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "fc48c3f7b8ed9d0aef47376a145289b5",
"sha256": "9e420b93ee5efb741545f61d5904fbe6f1fb723dafd07ace90bbea7232a9b7aa"
},
"downloads": -1,
"filename": "ixml-0.1.0.zip",
"has_sig": false,
"md5_digest": "fc48c3f7b8ed9d0aef47376a145289b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17645,
"upload_time": "2013-08-17T13:25:39",
"url": "https://files.pythonhosted.org/packages/a8/d5/216faa51321d92239ce6ad95781c7c9eb486c9b9c54acb3209c8026dc1a8/ixml-0.1.0.zip"
}
]
}