{ "info": { "author": "Georg Brandl", "author_email": "georg@python.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": ".. -*- restructuredtext -*-\n\n============================================\nREADME for Karnickel - AST Macros for Python\n============================================\n\n\"it's no ordinary rabbit...\"\n\n\nWhat is it?\n===========\n\nKarnickel is a small library that allows you to use macros (similar to those\nfound in Lisp) in Python code. In a nutshell, macros allow you to insert code\n(the macro *definition*) at a different point in the code (the macro *call*).\nIt is different from calling functions in that the code is inserted *before* it\nis even compiled.\n\n(\"Karnickel\" is German for \"rabbit\", and there's a vicious killer\nrabbit in \"Monty Python and the Holy Grail\" that is best left alone...)\n\n\nUsing\n=====\n\nUse Python 2.6+. You can put macros in any module. Macro definitions are\nPython functions, like this::\n\n from karnickel import macro\n\n @macro\n def macroname(arg1, arg2):\n ... macro contents ...\n\nOptional arguments are not supported.\n\nIf the contents are a single expression (no ``return``), the macro is an\n*expression macro*. Otherwise, it is a *block macro*. If it contains a\nstatement consisting of only ``__body__``, it is a block macro *with body*.\n\nFor using the macros, you must install the import hook::\n\n import karnickel\n karnickel.install_hook()\n\n*Then*, you can import modules that use macros like this::\n\n from module.__macros__ import macro1, macro2\n\nThat is, append ``.__macros__`` to the name of the module that contains the\nmacros. Only ``from``-imports are supported.\n\nUsage depends on the macro type:\n\n* Expression macros can be used everywhere as expressions. Arguments are put\n into the places of macro arguments.\n\n* Block macros without body can only be used as an expression statement --\n i.e.::\n\n macroname(arg1, arg2)\n\n* Block macros with body must be used with a ``with`` statement::\n\n with macroname(arg1, arg2):\n body\n\n Arguments are put into the places of macro arguments, and the body is put into\n the place of ``__body__`` in the macro definition.\n\nProper docs may follow as soon as I can find a decent documentation tool.\n\n\nWhy?\n====\n\nWhy not? Seriously, this is a demonstration of what you can do with the Python\nAST, especially the standard ``ast`` module, and import hooks. Besides, it's\nbeen fun.\n\n\nInstalling\n==========\n\nUse ``setup.py``::\n\n sudo python setup.py install\n\n\nAuthor\n======\n\nGeorg Brandl ", "description_content_type": null, "docs_url": null, "download_url": "http://pypi.python.org/pypi/karnickel", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://dev.pocoo.org/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "karnickel", "package_url": "https://pypi.org/project/karnickel/", "platform": "any", "project_url": "https://pypi.org/project/karnickel/", "project_urls": { "Download": "http://pypi.python.org/pypi/karnickel", "Homepage": "http://dev.pocoo.org/" }, "release_url": "https://pypi.org/project/karnickel/0.2/", "requires_dist": null, "requires_python": null, "summary": "Python macros using the AST", "version": "0.2" }, "last_serial": 793902, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "72119e846376743240a0221e1852a36d", "sha256": "f953c7c44a582af8e7a5bca609d82085f293a03f52d37b2c7df92937f38213c6" }, "downloads": -1, "filename": "karnickel-0.1.tar.gz", "has_sig": false, "md5_digest": "72119e846376743240a0221e1852a36d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7561, "upload_time": "2010-05-01T20:22:50", "url": "https://files.pythonhosted.org/packages/c4/23/4163b1264650ea723c7eede7812d3eaff846dcce4142f664fbd906ab70d1/karnickel-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "5539e0c4c1aa786d3be417d62cb7f055", "sha256": "293a0f467ed287ec8806b33e005bb1e83e2e4e281a60d8e45453c2eeafc41cf3" }, "downloads": -1, "filename": "karnickel-0.2.tar.gz", "has_sig": false, "md5_digest": "5539e0c4c1aa786d3be417d62cb7f055", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8631, "upload_time": "2011-08-16T08:39:16", "url": "https://files.pythonhosted.org/packages/a5/1a/05854c64bb07feeca077d4120aab9dd1273b3f368831393c86b20751fb2b/karnickel-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5539e0c4c1aa786d3be417d62cb7f055", "sha256": "293a0f467ed287ec8806b33e005bb1e83e2e4e281a60d8e45453c2eeafc41cf3" }, "downloads": -1, "filename": "karnickel-0.2.tar.gz", "has_sig": false, "md5_digest": "5539e0c4c1aa786d3be417d62cb7f055", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8631, "upload_time": "2011-08-16T08:39:16", "url": "https://files.pythonhosted.org/packages/a5/1a/05854c64bb07feeca077d4120aab9dd1273b3f368831393c86b20751fb2b/karnickel-0.2.tar.gz" } ] }