{ "info": { "author": "Valentin LAB", "author_email": "valentin.lab@kalysto.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=========================\nkids.ansi\n=========================\n\n.. image:: https://pypip.in/v/kids.ansi/badge.png\n :target: https://pypi.python.org/pypi/kids.ansi\n\n.. image:: https://secure.travis-ci.org/0k/kids.ansi.png?branch=master\n :target: http://travis-ci.org/0k/kids.ansi\n\n\n``kids.ansi`` is a Python library providing helpers when writing command\nline utilities in python. It's part of 'Kids' (for Keep It Dead Simple)\nlibrary, but can be used with no extra dependencies.\n\n\nMaturity\n--------\n\nThis code is in alpha stage. Some part of it are ongoing reflexions.\nWhat is documented here shouldn't change much, and is actually working.\n\n\nFeatures\n--------\n\nusing ``kids.ansi``:\n\n- Access and insert ANSI escape sequences manualy.\n- Or use the ``aformat`` wrapper for full abstraction.\n\nNote that it's very close to what ``termcolor`` does.\n\n\nUsage\n-----\n\n\naformat\n\"\"\"\"\"\"\"\n\n``kids.ansi`` features a ``aformat`` function to return a string\nready for print with the ansi character inside::\n\n >>> from kids.ansi import aformat\n\n >>> aformat(\"You\", fg=\"red\")\n aformat('\\x1b[31mYou\\x1b[39m')\n\n >>> aformat(\"Hello You, how are you?\", fg=\"black\", bg=\"blue\", attrs=[\"bold\", ])\n aformat('\\x1b[30m\\x1b[44mHello You, how are you?\\x1b[39m\\x1b[49m')\n\nNotice that ``aformat`` is somewhat clever ::\n\n >>> you = aformat(\"You\", fg=\"red\")\n >>> aformat(\"Hello, Are \" + you + \" Well\", fg=\"blue\")\n aformat('\\x1b[34mHello, Are \\x1b[31mYou\\x1b[34m Well\\x1b[39m')\n\nNotice how the ending ansi sequence of the ``you`` sets back the blue\ncolor and not the default one. So the word \"Well\" still appears in blue.\n\n``aformat`` is clever, but still with some limitation, hitting mainly\nstring interpolation::\n\n >>> aformat(\"Hello, Are %s Well\" % you, fg=\"blue\")\n aformat('\\x1b[34mHello, Are \\x1b[31mYou\\x1b[39m Well\\x1b[39m')\n\nThe word \"Well\" is NOT in blue. This is an issue.\n\nAccess to ansi sequences\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nAccess to raw ANSI color sequence can be done via FG, BG, ATTR, and\nCTL attritbutes dicts::\n\n >>> from kids.ansi import FG, BG, ATTR, CTL\n\n >>> FG.white\n '\\x1b[37m'\n >>> BG.red\n '\\x1b[41m'\n >>> BG.default\n '\\x1b[49m'\n >>> ATTR.bold\n '\\x1b[1m'\n >>> ATTR.unbold\n '\\x1b[21m'\n >>> CTL.reset\n '\\x1b[0m'\n\nAs these are dicts, and you don't remember all the accessible keys, you can\nintrospect them easily::\n\n >>> sorted(ATTR) ## doctest: +NORMALIZE_WHITESPACE\n ['blink', 'bold', 'conceal', 'faint', 'italic', 'reverse', 'strike',\n 'unblink', 'unbold', 'unconceal', 'underline', 'unfaint', 'unitalic',\n 'unreverse', 'unstrike', 'ununderline']\n\nYou could then::\n\n >>> \"Hmm \" + FG.red + \"Hello\" + FG.default + \" you.\"\n 'Hmm \\x1b[31mHello\\x1b[39m you.'\n\nAnd print it.", "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/0k/kids.ansi", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "kids.ansi", "package_url": "https://pypi.org/project/kids.ansi/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/kids.ansi/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/0k/kids.ansi" }, "release_url": "https://pypi.org/project/kids.ansi/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Kids python ANSI string library", "version": "0.0.1" }, "last_serial": 1386518, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0a472c4658349a4472aa7a0aa37d1293", "sha256": "47386c534acc25f236c379e04379931884ff4f1b589dbc1175b7ca89ee3e50f4" }, "downloads": -1, "filename": "kids.ansi-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0a472c4658349a4472aa7a0aa37d1293", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6223, "upload_time": "2015-01-18T06:16:12", "url": "https://files.pythonhosted.org/packages/86/23/b58b70987bcdad412f46df7118176ac133400482e95841c7b424c4e7cac5/kids.ansi-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0a472c4658349a4472aa7a0aa37d1293", "sha256": "47386c534acc25f236c379e04379931884ff4f1b589dbc1175b7ca89ee3e50f4" }, "downloads": -1, "filename": "kids.ansi-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0a472c4658349a4472aa7a0aa37d1293", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6223, "upload_time": "2015-01-18T06:16:12", "url": "https://files.pythonhosted.org/packages/86/23/b58b70987bcdad412f46df7118176ac133400482e95841c7b424c4e7cac5/kids.ansi-0.0.1.tar.gz" } ] }