pypager


Namepypager JSON
Version 3.0.1 PyPI version JSON
download
home_pagehttps://github.com/jonathanslenders/pypager
SummaryPure Python pager (like "more" and "less").
upload_time2023-02-21 16:30:39
maintainer
docs_urlNone
authorJonathan Slenders
requires_python>=3.6
licenseLICENSE
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            pypager
=======

|Build Status|  |PyPI|  |License|

*A $PAGER in pure Python*

::

    pip install pypager

Pypager can be used as a stand-alone application, or as a library.


What is a pager?
----------------

A pager is a terminal program that can be used to view the content of a file,
or the output stream from another application.

For instance, when we run ``man vim``, the actual content is displayed in a
pager, according to the ``$PAGER`` environment variable.

Important for a pager is that the input can be streamed. For instance when we
execute ``find / | pypager``; we don't want to wait for the whole file system
to be traversed, before displaying anything. Data is only read from the input
pipe, when it needs to be displayed.

Popular pager applications are ``more``, ``less`` and ``most``.


Features
--------

- Highlighting of text [0].
- Searching.
- Many key bindings from ``less`` are implemented.

[0] (It understands the output of man pages, ANSI escape codes and further, it
can use Pygments to highlight about any file.)


Usage
-----

.. code:: sh

    # Install it.
    pip install pypager

    # Tell the environment to use this pager. Put the following line in
    # ~/.bashrc if you like.
    export PAGER=pypager

    # Following commands, and many others should pick up the pager.
    man vim
    git diff

    # View a file, using this pager.
    pypager some_source_code.py


As a library
------------

.. code:: python

    from pypager.source import GeneratorSource
    from pypager.pager import Pager


    def generate_a_lot_of_content():
        """
        This is a function that generates content on the fly.
        It's called when the pager needs to display more content.

        This should yield prompt_toolkit `(style_string, text)` tuples.
        """
        counter = 0
        while True:
            yield [("", 'line: %i\n' % counter)]
            counter += 1


    if __name__ == '__main__':
        p = Pager()
        p.add_source(GeneratorSource(generate_a_lot_of_content())
        p.run()


.. |Build Status| image:: https://api.travis-ci.org/prompt-toolkit/pypager.svg?branch=master
    :target: https://travis-ci.org/prompt-toolkit/pypager#

.. |License| image:: https://img.shields.io/github/license/prompt-toolkit/pypager.svg
    :target: https://github.com/prompt-toolkit/pypager/blob/master/LICENSE

.. |PyPI| image:: https://pypip.in/version/pypager/badge.svg
    :target: https://pypi.python.org/pypi/pypager/
    :alt: Latest Version

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jonathanslenders/pypager",
    "name": "pypager",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jonathan Slenders",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a2/94/fb3cf81608d8a5aaf5bbac7e8f331e1ccc4501d7351957b72f0a8eb0d9f5/pypager-3.0.1.tar.gz",
    "platform": null,
    "description": "pypager\n=======\n\n|Build Status|  |PyPI|  |License|\n\n*A $PAGER in pure Python*\n\n::\n\n    pip install pypager\n\nPypager can be used as a stand-alone application, or as a library.\n\n\nWhat is a pager?\n----------------\n\nA pager is a terminal program that can be used to view the content of a file,\nor the output stream from another application.\n\nFor instance, when we run ``man vim``, the actual content is displayed in a\npager, according to the ``$PAGER`` environment variable.\n\nImportant for a pager is that the input can be streamed. For instance when we\nexecute ``find / | pypager``; we don't want to wait for the whole file system\nto be traversed, before displaying anything. Data is only read from the input\npipe, when it needs to be displayed.\n\nPopular pager applications are ``more``, ``less`` and ``most``.\n\n\nFeatures\n--------\n\n- Highlighting of text [0].\n- Searching.\n- Many key bindings from ``less`` are implemented.\n\n[0] (It understands the output of man pages, ANSI escape codes and further, it\ncan use Pygments to highlight about any file.)\n\n\nUsage\n-----\n\n.. code:: sh\n\n    # Install it.\n    pip install pypager\n\n    # Tell the environment to use this pager. Put the following line in\n    # ~/.bashrc if you like.\n    export PAGER=pypager\n\n    # Following commands, and many others should pick up the pager.\n    man vim\n    git diff\n\n    # View a file, using this pager.\n    pypager some_source_code.py\n\n\nAs a library\n------------\n\n.. code:: python\n\n    from pypager.source import GeneratorSource\n    from pypager.pager import Pager\n\n\n    def generate_a_lot_of_content():\n        \"\"\"\n        This is a function that generates content on the fly.\n        It's called when the pager needs to display more content.\n\n        This should yield prompt_toolkit `(style_string, text)` tuples.\n        \"\"\"\n        counter = 0\n        while True:\n            yield [(\"\", 'line: %i\\n' % counter)]\n            counter += 1\n\n\n    if __name__ == '__main__':\n        p = Pager()\n        p.add_source(GeneratorSource(generate_a_lot_of_content())\n        p.run()\n\n\n.. |Build Status| image:: https://api.travis-ci.org/prompt-toolkit/pypager.svg?branch=master\n    :target: https://travis-ci.org/prompt-toolkit/pypager#\n\n.. |License| image:: https://img.shields.io/github/license/prompt-toolkit/pypager.svg\n    :target: https://github.com/prompt-toolkit/pypager/blob/master/LICENSE\n\n.. |PyPI| image:: https://pypip.in/version/pypager/badge.svg\n    :target: https://pypi.python.org/pypi/pypager/\n    :alt: Latest Version\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "Pure Python pager (like \"more\" and \"less\").",
    "version": "3.0.1",
    "project_urls": {
        "Homepage": "https://github.com/jonathanslenders/pypager"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91a000480b4dd4e88a8833a691d219f1ad550d385ed898f0af7564486d5a62c0",
                "md5": "5cd8604b7527bf2210d5dcdf75d77c7b",
                "sha256": "f5169242fa7e46f5ffec225a667af664f8adf31616c84d99bf7ed8e898433930"
            },
            "downloads": -1,
            "filename": "pypager-3.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5cd8604b7527bf2210d5dcdf75d77c7b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 19196,
            "upload_time": "2023-02-21T16:30:37",
            "upload_time_iso_8601": "2023-02-21T16:30:37.108392Z",
            "url": "https://files.pythonhosted.org/packages/91/a0/00480b4dd4e88a8833a691d219f1ad550d385ed898f0af7564486d5a62c0/pypager-3.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a294fb3cf81608d8a5aaf5bbac7e8f331e1ccc4501d7351957b72f0a8eb0d9f5",
                "md5": "6c8b49ea9fe3d1d05bafab2da7bd0e5c",
                "sha256": "79c1fc8c4f2c9749dd58e5b29bfce48ca864a24898d1a1e0df1e7fe82d86ab44"
            },
            "downloads": -1,
            "filename": "pypager-3.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6c8b49ea9fe3d1d05bafab2da7bd0e5c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 17152,
            "upload_time": "2023-02-21T16:30:39",
            "upload_time_iso_8601": "2023-02-21T16:30:39.075493Z",
            "url": "https://files.pythonhosted.org/packages/a2/94/fb3cf81608d8a5aaf5bbac7e8f331e1ccc4501d7351957b72f0a8eb0d9f5/pypager-3.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-21 16:30:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jonathanslenders",
    "github_project": "pypager",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pypager"
}
        
Elapsed time: 0.42358s