{ "info": { "author": "Eric Florenzano", "author_email": "floguy@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introduction\r\n------------\r\n\r\nNZB is an XML-based file format for retrieving posts from NNTP (Usenet) \r\nservers.\r\nSince NZB is XML-based, it's relatively easy to build one-off parsers to parse\r\nNZB files. This project is an attempt to consolidate those many one-off NZB\r\nparsers into one simple interface.\r\n\r\nThis package includes three implementations: one based on expat, another \r\nbased\r\non ElementTree, and a final implementation based on lxml. The order in which\r\nthey were listed is in order of compatibility. The expat version should work on\r\nall versions of Python > 2.0, the lxml one will work on all versions > 2.5, and\r\nlxml will only work if you have lxml installed.\r\n\r\n\r\nA Note on Installing lxml\r\n-------------------------\r\n\r\nWhile lxml is not a requirement, I have had a hard time installing lxml in the\r\npast. I have found this set of commands to work perfectly::\r\n\r\n STATIC_DEPS=true easy_install 'lxml>=2.2beta4'\r\n STATIC_DEPS=true sudo easy_install 'lxml>=2.2beta4'\r\n\r\n\r\nAPI Documentation\r\n-----------------\r\n\r\n\r\nAccessing the Default Parser\r\n============================\r\n\r\nSimply import nzb_parser from the pynzb package. It's an instantiated version\r\nof the fastest available parser that your system can support.\r\n\r\n\r\nOther Parser Locations\r\n======================\r\n\r\n``ExpatNZBParser``:\r\n Available in the ``pynzb.expat_nzb`` namespace.\r\n\r\n``ETreeNZBParser``:\r\n Available in the ``pynzb.etree_nzb`` namespace.\r\n\r\n``LXMLNZBParser``:\r\n Available in the ``pynzb.lxml_nzb`` namespace.\r\n\r\n\r\nUsing the NZB Parser\r\n====================\r\n\r\nIf you're using a specific parser, like the ``ETreeNZBParser``, you will first\r\nhave to instantiate it::\r\n\r\n nzb_parser = ETreeNZBParser()\r\n\r\n\r\nOtherwise, you can just import the default parser for your system::\r\n\r\n from pynzb import nzb_parser\r\n\r\n\r\nThen, simply call the ``parse`` method, giving it the xml string as the only\r\nargument::\r\n\r\n files = nzb_parser.parse('')\r\n\r\n\r\nThis will return a list of ``NZBFiles`` for you to use.\r\n\r\n\r\nNZBFile Objects\r\n===============\r\n\r\nAll of the parsers return ``NZBFile`` objects, which are objects with the\r\nfollowing properties:\r\n\r\n``poster``:\r\n The name of the user who posted the file to the newsgroup.\r\n\r\n``date``:\r\n A ``datetime.date`` representation of when the server first saw the file.\r\n\r\n``subject``:\r\n The subject used when the user posted the file to the newsgroup.\r\n\r\n``groups``:\r\n A list of strings representing the newsgroups in which this file may be\r\n found.\r\n\r\n``segments``:\r\n A list of ``NZBSegment`` objects talking about where to get the contents\r\n of this file.\r\n\r\n\r\nNZBSegment Objects\r\n==================\r\n\r\nEach ``NZBFile`` has a list of ``NZBSegment`` objects, which include \r\ninformation\r\non how to retrieve a part of a file. Here's what you can find on an\r\n``NZBSegment`` object:\r\n\r\n``number``:\r\n The number of the segment in the list of files.\r\n\r\n``bytes``:\r\n The size of the segment, in bytes.\r\n\r\n``message_id``:\r\n The Message-ID of the segment (useful for retrieving the full contents)\r\n\r\n\r\nExample\r\n--------\r\n\r\nIn this example, we will grab an Ubuntu NZB and parse the file, printing out\r\nsome information about each file and its segments::\r\n\r\n from pynzb import nzb_parser\r\n from urllib2 import urlopen\r\n\r\n # Grab a sample Ubuntu NZB\r\n ubuntu_nzb = urlopen('http://media.eflorenzano.com/misc/sample-ubuntu-\r\nnzb.nzb').read()\r\n\r\n # Parse the NZB into files\r\n files = nzb_parser.parse(ubuntu_nzb)\r\n\r\n # Print out each file's subject and the first two segment message ids\r\n for nzb_file in files:\r\n print nzb_file.subject\r\n for segment in nzb_file.segments[:2]:\r\n print ' ' + segment.message_id\r\n if len(nzb_file.segments) > 2:\r\n print ' ...'", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ericflo/pynzb/tree/master", "keywords": "nzb,parser,xml", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pynzb", "package_url": "https://pypi.org/project/pynzb/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pynzb/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/ericflo/pynzb/tree/master" }, "release_url": "https://pypi.org/project/pynzb/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "pynzb is a unified API for parsing NZB files, with several concrete implementations included", "version": "0.1.0" }, "last_serial": 797456, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "63c74a36348ac28aa99732dcb8be8c59", "sha256": "0735b3889a1174bbb65418ee503629d3f5e4a63f04b16f46ffba18253ec3ef17" }, "downloads": -1, "filename": "pynzb-0.1.0.tar.gz", "has_sig": false, "md5_digest": "63c74a36348ac28aa99732dcb8be8c59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5598, "upload_time": "2009-05-11T08:14:43", "url": "https://files.pythonhosted.org/packages/b1/90/b71ca66e2fee3f46281b3ecc853abe407a5ecd0cb4898af5bab48af63590/pynzb-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "63c74a36348ac28aa99732dcb8be8c59", "sha256": "0735b3889a1174bbb65418ee503629d3f5e4a63f04b16f46ffba18253ec3ef17" }, "downloads": -1, "filename": "pynzb-0.1.0.tar.gz", "has_sig": false, "md5_digest": "63c74a36348ac28aa99732dcb8be8c59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5598, "upload_time": "2009-05-11T08:14:43", "url": "https://files.pythonhosted.org/packages/b1/90/b71ca66e2fee3f46281b3ecc853abe407a5ecd0cb4898af5bab48af63590/pynzb-0.1.0.tar.gz" } ] }