Skip to main content

Library for adding 'more' like paging functionality to your Python application

Project description

This library makes it easy to add more paginating to your application.

To see the operations available, press h at the --More-- prompt:

-------------------------------------------------------------------------------
Most commands can optionally be preceded by an integer argument k.
The default values are printed in brackets.
A star (*) indicates the value of k becomes the new default.
-------------------------------------------------------------------------------
<space>                Display next k lines of text [current screen size]
<return>               Display next k lines of text [1]*
q or Q or <interrupt>  Exit from more
=                      Display current line number
l                      Toggle printing line number on every line [currently disabled]
/<regular expression>  Search for kth occurrence of the regular expression [1]
n                      Search for kth occurrence of the last regular expression [1]
h or ?                 Display this help text
-------------------------------------------------------------------------------

How to use this

All you need to do is call paginate and pass in your input lines:

import more_or_less

more_or_less.paginate(input=iterator_or_queue)

This uses your terminal’s screen height, and prints the text to stdout.

Do you want to use something other than stdout? Just pass in what output to use

more_or_less.paginate(input=iterator, output=stderr)

This can be any object that has a write and flush method

class MyCustomOutput(object):
    def write(self, text):
        pass

    def flush(self):
        pass

def paginate(iterator):
    more_or_less.paginate(input=iterator, myCustomOutput())

Advanced topics

Adding plugins

All actions you take at the more prompt (space for one more page, enter for one more line, and so on) are installed using plugins.

This makes it easy to extend the functionality.

TODO: Flesh out

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

more-or-less-0.1.5.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file more-or-less-0.1.5.tar.gz.

File metadata

  • Download URL: more-or-less-0.1.5.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for more-or-less-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2ce653b849cac607066a8605d57e9d2d6f11cf4f33d2d114356e0e87f2af9e35
MD5 5bbb9bf8d43653f31246fb8fdb242fd2
BLAKE2b-256 4ea9a1a5fa55bb5610bbed0f03b0cb097ea6cd9c7eb736968f533adbfbe4bae1

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page