pypager
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
# 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
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()
Metadata
Release files for pypager 3.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypager-3.0.1.tar.gz | 17.2 kB | Without provenance | Details for pypager-3.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypager-3.0.1-py3-none-any.whl | Python 3 | none | any | Details for pypager-3.0.1-py3-none-any.whl |
Total release size: 36.3 kB
Release files / pypager-3.0.1.tar.gz
| Download URL | pypager-3.0.1.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79c1fc8c4f2c9749dd58e5b29bfce48ca864a24898d1a1e0df1e7fe82d86ab44
|
|
BLAKE2b-256 checksum How to use checksums |
a294fb3cf81608d8a5aaf5bbac7e8f331e1ccc4501d7351957b72f0a8eb0d9f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / pypager-3.0.1-py3-none-any.whl
| Download URL | pypager-3.0.1-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5169242fa7e46f5ffec225a667af664f8adf31616c84d99bf7ed8e898433930
|
|
BLAKE2b-256 checksum How to use checksums |
91a000480b4dd4e88a8833a691d219f1ad550d385ed898f0af7564486d5a62c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for pypager 3.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.