{ "info": { "author": "Nathan Van Gheem", "author_email": "vangheem@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Introduction\r\n============\r\n\r\nBumblebee is a deliverance-like html transformation framwork\r\nimplementation that only works on the output an html document.\r\n\r\nIt doesn't use xslt so it isn't as fast as what Diazo is; however,\r\nit accomplishes the very simple use-case of moving elements around\r\non html output.\r\n\r\n\r\nWhy\r\n---\r\n\r\nBecause I almost never needed the full-fledge deliverance approach\r\nfor what I wanted to do. In fact, it was usually an annoyance when\r\nall I wanted to do was move an element around on a page.\r\n\r\n\r\nHow-to Use\r\n==========\r\n\r\nConfigurating your transformations is done with a very xml syntax.\r\n\r\nExample:\r\n\r\nHTML::\r\n\r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n\r\n\r\nRules XML::\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\nRunning it through::\r\n \r\n from bumblebee import transform\r\n from repoze.xmliter.utils import getHTMLSerializer\r\n from bumblebee.xml import convertRules\r\n\r\n html = getHTMLSerializer(output)\r\n rules = convertRules(rules_xml)\r\n result = transform(html, rules)\r\n\r\n\r\nSelectors\r\n---------\r\n\r\nFor xml configuration that selects elements, you can use CSS selectors(default)\r\nor XPath.\r\n\r\nTo use XPath, just append '-path' onto the node name::\r\n\r\n \r\n\r\n\r\narbitrary html\r\n~~~~~~~~~~~~~~\r\n\r\nUse this to inject html into a page::\r\n\r\n \r\n
\r\n

hello, world

\r\n
\r\n
\r\n\r\n\r\nRules\r\n-----\r\n\r\nBefore\r\n~~~~~~\r\n\r\nMove an element before another element::\r\n\r\n \r\n\r\nMoves \"#foo\" before \"#bar\"\r\n\r\nAfter\r\n~~~~~\r\n\r\nMove an element after another::\r\n\r\n \r\n\r\nMoves \"#foo\" after \"#bar\"\r\n\r\nDrop\r\n~~~~\r\n\r\nRemove an element from the dom::\r\n\r\n \r\n\r\nReplace\r\n~~~~~~~\r\n\r\nReplace an element with another::\r\n\r\n \r\n\r\nReplaces \"#dst\" with \"#src\"\r\n\r\n\r\nClass\r\n~~~~~\r\n\r\nAdd or remove classes from an element::\r\n\r\n \r\n\r\nRemove the classes \"one\" and \"two\" from \"#foo\" and add\r\nthe classes \"three\" and \"four\".\r\n\r\n\r\nTag\r\n~~~\r\n\r\nChange a tag::\r\n\r\n \r\n\r\nGroup\r\n~~~~~\r\n\r\nGroup rules together with a conditions::\r\n\r\n \r\n \r\n \r\n\r\nPerforms some rules if \"#foo\" is in the document.\r\n\r\n\r\nConditions\r\n----------\r\n\r\nif-content\r\n~~~~~~~~~~\r\n\r\nPerforms actions if the selector is found in the document::\r\n\r\n \r\n\r\n\r\nnot conditiion\r\n~~~~~~~~~~~~~~\r\n\r\nAny condition can be negated for the opposite affect::\r\n\r\n \r\n\r\n\r\nExtending\r\n---------\r\n\r\nCreating a Rule::\r\n \r\n from bumblebee.rules import BaseDouble\r\n class Append(BaseDouble):\r\n def __call__(self, root):\r\n src, dst, skip = self.process_nodes(root)\r\n if skip:\r\n return None\r\n dst = dst[0]\r\n for el in dst:\r\n dst.append(el)\r\n return src\r\n \r\n from bumblebee.xml import addTag\r\n addTag('append', Append)\r\n\r\nTo use the rule, you would::\r\n\r\n \r\n\r\n\r\nCreating a Condition::\r\n\r\n from bumblebee.conditions import BaseIf\r\n class IfPath(BaseIf):\r\n def __init__(self, path, extras={}):\r\n super(IfPath, self).__init__(extras)\r\n self.path = path\r\n def __call__(self, root):\r\n req = self.extras['request']\r\n path = req['PATH_INFO']\r\n if self.path.startswith('/'):\r\n return path.startswith(self.path)\r\n else:\r\n return self.path in path\r\n from bumblebee.xml import addCondition\r\n addCondition('path', IfPath)\r\n\r\nTo use this condition, you would::\r\n\r\n \r\n\r\nor::\r\n\r\n \r\n\r\n\r\nCHANGELOG\r\n=========\r\n\r\n\r\n1.0a2 ~ (2011-09-22)\r\n--------------------\r\n\r\n- add support for arbitrary html\r\n\r\n- better support for adding new selectors, conditions, rules\r\n\r\n- better parsing\r\n\r\n- better handle extras parameters so that rules can be more\r\n easily cached", "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/vangheem/Bumblebee", "keywords": "transform deliverance diazo lxml", "license": "UNKNOWN", "maintainer": "", "maintainer_email": "", "name": "Bumblebee", "package_url": "https://pypi.org/project/Bumblebee/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Bumblebee/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/vangheem/Bumblebee" }, "release_url": "https://pypi.org/project/Bumblebee/1.0a2/", "requires_dist": null, "requires_python": null, "summary": "deliverance-like implementation that only works on html output(no theme file)", "version": "1.0a2" }, "last_serial": 783889, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "825e5aeaeec2c10ed77f615ee94cb040", "sha256": "842322752b6c910bf9a1061dd8148c62cf2a32a748f97e85a77f3dae1e3e7714" }, "downloads": -1, "filename": "Bumblebee-1.0a1.zip", "has_sig": false, "md5_digest": "825e5aeaeec2c10ed77f615ee94cb040", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8944, "upload_time": "2011-09-05T23:51:45", "url": "https://files.pythonhosted.org/packages/9e/c0/62643a6aa45d84b1c0ac2fdd7f9bd4666bf420b8b3891c4966443a6885de/Bumblebee-1.0a1.zip" } ], "1.0a2": [ { "comment_text": "", "digests": { "md5": "a3d7de6d1e29f2d18d6bd5d43e3d48fa", "sha256": "34efd460ceee668e629e958cffe82610a81c14fe919a2d6533ad9dc4e60278a4" }, "downloads": -1, "filename": "Bumblebee-1.0a2.zip", "has_sig": false, "md5_digest": "a3d7de6d1e29f2d18d6bd5d43e3d48fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19112, "upload_time": "2011-09-22T08:31:56", "url": "https://files.pythonhosted.org/packages/de/f7/32f866780a9b41683d90f427b27dba97aeb9ba04c3ff3d0e93cc26653ded/Bumblebee-1.0a2.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a3d7de6d1e29f2d18d6bd5d43e3d48fa", "sha256": "34efd460ceee668e629e958cffe82610a81c14fe919a2d6533ad9dc4e60278a4" }, "downloads": -1, "filename": "Bumblebee-1.0a2.zip", "has_sig": false, "md5_digest": "a3d7de6d1e29f2d18d6bd5d43e3d48fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19112, "upload_time": "2011-09-22T08:31:56", "url": "https://files.pythonhosted.org/packages/de/f7/32f866780a9b41683d90f427b27dba97aeb9ba04c3ff3d0e93cc26653ded/Bumblebee-1.0a2.zip" } ] }