{ "info": { "author": "Ask Solem", "author_email": "ask@celeryproject.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "##############################################\n literal.py - Python code generation tool\n##############################################\n\n:Version: 1.0.0\n\nSynopsis\n========\n\nLiteral is a fun weekend project to create a way to generate python\ncode with Python code. Instead of having string literals of Python\ncode, you use ``literal.py`` objects that remembers the operations\ndone to them, and the history of operations is the resulting\nPython program.\n\nThis is just an experiment that I wanted to play with;\nIt's usefulness is not proven, and more than likely\nthis will be thrown away as a failed experiment. So use\nwith care and caution.\n\nQuick overview\n--------------\n\n::\n\n import literal\n\n @literal.py\n def unpack_octet(x, payload, offset, unpack_from):\n x <<= unpack_from('B', payload, offset)\n offset += 1\n\n print(unpack_octet())\n\nGives::\n\n x = unpack_from('B', payload, offset)\n offset += 1\n\n\nOr another example used to create argument unpackers\nfor the AMQP protocol::\n\n def unpack(method):\n\n @literal.py\n def body(p, payload, offset, unpack_from, argtuple, ssize):\n fields = method.fields\n names = p.tuple(*self.field_names)\n\n for i, fset in enumerate(fields):\n if len(fset) == 1:\n for field in fset:\n name = p.var(field.name)\n if field.format == '*':\n # This is a string payload,\n # don't have to unpack\n name <<= payload[offset:offset + ssize]\n offset += ssize\n else:\n # A single field to unpack\n name <<= unpack_from(struct_format(field.format),\n payload, offset)[0]\n offset += field.size\n else:\n # A list of field to unpack\n these = p.tuple(*fset.names)\n these <<= unpack_from(struct_format(fset.format),\n payload, offset)\n offset += sum(f.size for f in fset)\n return names\n\n return body().as_fun(lambda payload, offset: 1,\n method.name)\n\n\nWould generate the following code for the AMQP method ``basic_deliver``::\n\n def deliver(payload, offset):\n ssize = unpack_from('B', payload, offset)[0]\n offset += 1\n consumer_tag = payload[offset:offset + ssize]\n offset += ssize\n delivery_tag, redelivered, ssize = unpack_from('QBB', payload, offset)\n offset += 10\n exchange = payload[offset:offset + ssize]\n offset += ssize\n ssize = unpack_from('B', payload, offset)[0]\n offset += 1\n routing_key = payload[offset:offset + ssize]\n offset += ssize\n return (consumer_tag, delivery_tag, redelivered,\n exchange, routing_key)\n\n\nMore documentation to come.\n\nInstallation\n============\n\nYou can install `literal` either via the Python Package Index (PyPI)\nor from source.\n\nTo install using `pip`,::\n\n $ pip install literal\n\nTo install using `easy_install`,::\n\n $ easy_install literal\n\nIf you have downloaded a source tarball you can install it\nby doing the following,::\n\n $ python setup.py build\n # python setup.py install # as root\n\n\nBug tracker\n===========\n\nIf you have any suggestions, bug reports or annoyances please report them\nto our issue tracker at http://github.com/ask/literal.py/issues/\n\nContributing\n============\n\nDevelopment of `literal.py` happens at Github:\nhttp://github.com/ask/literal.py\n\nYou are highly encouraged to participate in the development. If you don't\nlike Github (for some reason) you're welcome to send regular patches.\n\nLicense\n=======\n\nThis software is licensed under the `New BSD License`. See the `LICENSE`\nfile in the top distribution directory for the full license text.", "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/ask/literal.py/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "literal", "package_url": "https://pypi.org/project/literal/", "platform": "any", "project_url": "https://pypi.org/project/literal/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/ask/literal.py/" }, "release_url": "https://pypi.org/project/literal/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "Python code generation tool.", "version": "1.0.0" }, "last_serial": 794251, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "30f766764916eb75445c83c63a68b94f", "sha256": "68e5502d66eb8ccb46159235441dd0b65bcd5ab2ac57075101860c35d1b7208d" }, "downloads": -1, "filename": "literal-1.0.0.tar.gz", "has_sig": false, "md5_digest": "30f766764916eb75445c83c63a68b94f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11734, "upload_time": "2011-12-05T16:27:27", "url": "https://files.pythonhosted.org/packages/fd/41/6b7c7cd9a1e51cd1a8751353bfe004d00c9f9a33bd3e4410b6e70b28ea5b/literal-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "30f766764916eb75445c83c63a68b94f", "sha256": "68e5502d66eb8ccb46159235441dd0b65bcd5ab2ac57075101860c35d1b7208d" }, "downloads": -1, "filename": "literal-1.0.0.tar.gz", "has_sig": false, "md5_digest": "30f766764916eb75445c83c63a68b94f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11734, "upload_time": "2011-12-05T16:27:27", "url": "https://files.pythonhosted.org/packages/fd/41/6b7c7cd9a1e51cd1a8751353bfe004d00c9f9a33bd3e4410b6e70b28ea5b/literal-1.0.0.tar.gz" } ] }