akshay-jay


Nameakshay-jay JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryA small example package
upload_time2023-10-27 07:55:44
maintainer
docs_urlNone
author
requires_python>=3
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tutorial
https://packaging.python.org/en/latest/tutorials/packaging-projects/

=========
Blessings
=========

Coding with Blessings looks like this... ::

    from blessings import Terminal

    t = Terminal()

    print t.bold('Hi there!')
    print t.bold_red_on_bright_green('It hurts my eyes!')

    with t.location(0, t.height - 1):
        print 'This is at the bottom.'

Or, for byte-level control, you can drop down and play with raw terminal
capabilities::

    print '{t.bold}All your {t.red}bold and red base{t.normal}'.format(t=t)
    print t.wingo(2)

`Full API Reference <https://blessings.readthedocs.io/>`_

The Pitch
=========

Blessings lifts several of curses_' limiting assumptions, and it makes your
code pretty, too:

* Use styles, color, and maybe a little positioning without necessarily
  clearing the whole
  screen first.
* Leave more than one screenful of scrollback in the buffer after your program
  exits, like a well-behaved command-line app should.
* Get rid of all those noisy, C-like calls to ``tigetstr`` and ``tparm``, so
  your code doesn't get crowded out by terminal bookkeeping.
* Act intelligently when somebody redirects your output to a file, omitting the
  terminal control codes the user doesn't want to see (optional).

.. _curses: http://docs.python.org/library/curses.html

Before And After
----------------

Without Blessings, this is how you'd print some underlined text at the bottom
of the screen::

    from curses import tigetstr, setupterm, tparm
    from fcntl import ioctl
    from os import isatty
    import struct
    import sys
    from termios import TIOCGWINSZ

    # If we want to tolerate having our output piped to other commands or
    # files without crashing, we need to do all this branching:
    if hasattr(sys.stdout, 'fileno') and isatty(sys.stdout.fileno()):
        setupterm()
        sc = tigetstr('sc')
        cup = tigetstr('cup')
        rc = tigetstr('rc')
        underline = tigetstr('smul')
        normal = tigetstr('sgr0')
    else:
        sc = cup = rc = underline = normal = ''
    print sc  # Save cursor position.
    if cup:
        # tigetnum('lines') doesn't always update promptly, hence this:
        height = struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, '\000' * 8))[0]
        print tparm(cup, height - 1, 0)  # Move cursor to bottom.
    print 'This is {under}underlined{normal}!'.format(under=underline,
                                                      normal=normal)
    print rc  # Restore cursor position.

That was long and full of incomprehensible trash! Let's try it again, this time
with Blessings::

    from blessings import Terminal

    term = Terminal()
    with term.location(0, term.height - 1):
        print 'This is', term.underline('pretty!')

Much better.

What It Provides
================

Blessings provides just one top-level object: ``Terminal``. Instantiating a
``Terminal`` figures out whether you're on a terminal at all and, if so, does
any necessary terminal setup. After that, you can proceed to ask it all sorts
of things about the terminal. Terminal terminal terminal.


    print 'All your {t.red}base {t.underline}are belong to us{t.normal}'.format(t=term)

Simple capabilities of interest include...

* ``bold``
* ``reverse``
* ``underline``
* ``no_underline`` (which turns off underlining)
* ``blink``
* ``normal`` (which turns off everything, even colors)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "akshay-jay",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "akshayj <author@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/1a/15/fc95032e20b11cebc1a5ac657b4a4040660e48ff0b111fe2ea16d206e1ee/akshay_jay-0.0.2.tar.gz",
    "platform": null,
    "description": "# Tutorial\nhttps://packaging.python.org/en/latest/tutorials/packaging-projects/\n\n=========\nBlessings\n=========\n\nCoding with Blessings looks like this... ::\n\n    from blessings import Terminal\n\n    t = Terminal()\n\n    print t.bold('Hi there!')\n    print t.bold_red_on_bright_green('It hurts my eyes!')\n\n    with t.location(0, t.height - 1):\n        print 'This is at the bottom.'\n\nOr, for byte-level control, you can drop down and play with raw terminal\ncapabilities::\n\n    print '{t.bold}All your {t.red}bold and red base{t.normal}'.format(t=t)\n    print t.wingo(2)\n\n`Full API Reference <https://blessings.readthedocs.io/>`_\n\nThe Pitch\n=========\n\nBlessings lifts several of curses_' limiting assumptions, and it makes your\ncode pretty, too:\n\n* Use styles, color, and maybe a little positioning without necessarily\n  clearing the whole\n  screen first.\n* Leave more than one screenful of scrollback in the buffer after your program\n  exits, like a well-behaved command-line app should.\n* Get rid of all those noisy, C-like calls to ``tigetstr`` and ``tparm``, so\n  your code doesn't get crowded out by terminal bookkeeping.\n* Act intelligently when somebody redirects your output to a file, omitting the\n  terminal control codes the user doesn't want to see (optional).\n\n.. _curses: http://docs.python.org/library/curses.html\n\nBefore And After\n----------------\n\nWithout Blessings, this is how you'd print some underlined text at the bottom\nof the screen::\n\n    from curses import tigetstr, setupterm, tparm\n    from fcntl import ioctl\n    from os import isatty\n    import struct\n    import sys\n    from termios import TIOCGWINSZ\n\n    # If we want to tolerate having our output piped to other commands or\n    # files without crashing, we need to do all this branching:\n    if hasattr(sys.stdout, 'fileno') and isatty(sys.stdout.fileno()):\n        setupterm()\n        sc = tigetstr('sc')\n        cup = tigetstr('cup')\n        rc = tigetstr('rc')\n        underline = tigetstr('smul')\n        normal = tigetstr('sgr0')\n    else:\n        sc = cup = rc = underline = normal = ''\n    print sc  # Save cursor position.\n    if cup:\n        # tigetnum('lines') doesn't always update promptly, hence this:\n        height = struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, '\\000' * 8))[0]\n        print tparm(cup, height - 1, 0)  # Move cursor to bottom.\n    print 'This is {under}underlined{normal}!'.format(under=underline,\n                                                      normal=normal)\n    print rc  # Restore cursor position.\n\nThat was long and full of incomprehensible trash! Let's try it again, this time\nwith Blessings::\n\n    from blessings import Terminal\n\n    term = Terminal()\n    with term.location(0, term.height - 1):\n        print 'This is', term.underline('pretty!')\n\nMuch better.\n\nWhat It Provides\n================\n\nBlessings provides just one top-level object: ``Terminal``. Instantiating a\n``Terminal`` figures out whether you're on a terminal at all and, if so, does\nany necessary terminal setup. After that, you can proceed to ask it all sorts\nof things about the terminal. Terminal terminal terminal.\n\n\n    print 'All your {t.red}base {t.underline}are belong to us{t.normal}'.format(t=term)\n\nSimple capabilities of interest include...\n\n* ``bold``\n* ``reverse``\n* ``underline``\n* ``no_underline`` (which turns off underlining)\n* ``blink``\n* ``normal`` (which turns off everything, even colors)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A small example package",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/pypa/sampleproject"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e9dfdf680b10c9330f3f27ba1ae927c91098599eccd2f71f35910aed8100a4e3",
                "md5": "d13833065c9222bf43b851d0bb40aadc",
                "sha256": "22a16c2e2ebe856461e2d154da8192b95c3989885c292614bd5629940032e1bd"
            },
            "downloads": -1,
            "filename": "akshay_jay-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d13833065c9222bf43b851d0bb40aadc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 4304,
            "upload_time": "2023-10-27T07:55:42",
            "upload_time_iso_8601": "2023-10-27T07:55:42.698455Z",
            "url": "https://files.pythonhosted.org/packages/e9/df/df680b10c9330f3f27ba1ae927c91098599eccd2f71f35910aed8100a4e3/akshay_jay-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a15fc95032e20b11cebc1a5ac657b4a4040660e48ff0b111fe2ea16d206e1ee",
                "md5": "601c30b6d9204d2ba9ef240307fbd883",
                "sha256": "8791cd8017c14bef1b65d59dba1e1d2ca7ae319ff00499964e966b4bc65b54ae"
            },
            "downloads": -1,
            "filename": "akshay_jay-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "601c30b6d9204d2ba9ef240307fbd883",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 3908,
            "upload_time": "2023-10-27T07:55:44",
            "upload_time_iso_8601": "2023-10-27T07:55:44.743176Z",
            "url": "https://files.pythonhosted.org/packages/1a/15/fc95032e20b11cebc1a5ac657b4a4040660e48ff0b111fe2ea16d206e1ee/akshay_jay-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-27 07:55:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pypa",
    "github_project": "sampleproject",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "akshay-jay"
}
        
Elapsed time: 0.24383s