pzp


Namepzp JSON
Version 0.0.23 PyPI version JSON
download
home_pagehttp://github.com/andreax79/pzp
SummaryPure-python fzf-inspired element picker
upload_time2023-11-13 12:49:10
maintainer
docs_urlNone
authorAndrea Bonomi
requires_python>=3.6
licenseMIT
keywords fzf picker cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pzp
==============

Pure-python fzf-inspired element picker

[![Build Status](https://github.com/andreax79/pzp/workflows/Tests/badge.svg)](https://github.com/andreax79/pzp/actions)
[![PyPI version](https://badge.fury.io/py/pzp.svg)](https://badge.fury.io/py/pzp)
[![PyPI](https://img.shields.io/pypi/pyversions/pzp.svg)](https://pypi.org/project/pzp)
[![Downloads](https://pepy.tech/badge/pzp/month)](https://pepy.tech/project/pzp)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Known Vulnerabilities](https://snyk-widget.herokuapp.com/badge/pip/pzp/badge.svg)](https://snyk.io/test/github/andreax79/pzp)
[![Documentation](https://readthedocs.org/projects/pzp/badge/?version=latest)](https://pzp.readthedocs.io/en/latest/)

Requirements
-----------
* Python 3.6+

Install
-------

```
pip install pzp
```

Usage
-----

```
from pzp import pzp
pzp(['a', 'b', 'c'])
```


### Layout

The finder by default starts in fullscreen mode. You can make it start below the
cursor with [`fullscreen=False`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.
Also, with the [`height`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument you can limit the window height.

```python
pzp(candidates=range(0, 1000), fullscreen=False, height=20)
```

[![asciicast](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ.svg)](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ?autoplay=1)

You can choose between the following layout using the [`layout`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.

* **default** Display from the bottom of the screen
* **reverse** Display from the top of the screen
* **reverse-list** Display from the top of the screen, prompt at the bottom

### Search syntax

The finder starts in "extended-search mode" where you can type in multiple search
terms delimited by spaces. e.g. `^music .mp3$ sbtrkt !fire`

| Token        | Match type                 | Description                          |
| ------------ | -------------------------- | ------------------------------------ |
| `t1 t2`      | tokens-match               | Items that include `t1` and `t2`     |
| `'star wars` | line-match (not-splitted)  | Items that include `star wars`       |
| `^music`     | prefix-exact-match         | Items that start with `music`        |
| `.py$`       | suffix-exact-match         | Items that end with `.py`            |
| `!fire`      | inverse-exact-match        | Items that do not include `fire`     |
| `!^music`    | inverse-prefix-exact-match | Items that do not start with `music` |
| `!.py$`      | inverse-suffix-exact-match | Items that do not end with `.py`     |

### Key/Event Bindings

[`keys_binding`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to bind one or more keys to one action.
You can use it to customize key bindings or implementing custom behaviors.

```python
try:
    item = pzp(
        candidates=candidates,
        keys_binding={
            "custom-action": ["ctrl-o"],
            "exclamation": ["!"]
        },
    )
    print(item)
except CustomAction as action:
    print(action.action)
    print(action.selected_item)
```

#### Available Keys

| Key                   | Synonyms type         |
| --------------------- | --------------------- |
| space                 |                       |
| tab                   |                       |
| btab                  | shift-tab             |
| enter                 |                       |
| esc                   |                       |
| insert                |                       |
| del                   |                       |
| bspace                | bs                    |
| up                    |                       |
| down                  |                       |
| left                  |                       |
| right                 |                       |
| home                  |                       |
| end                   |                       |
| pgdn                  | page-down             |
| pgup                  | page-up               |
| f1 - f12              |                       |
| ctrl-/                |                       |
| ctrl-\                |                       |
| ctrl-]                |                       |
| ctrl-^                |                       |
| ctrl-a - ctrl-z       |                       |
| any single character  |                       |

#### Available Actions

A key can be bound to one of following actions or to a custom action.

| *Action**                 | *Default binding*                     |
| ------------------------- | ------------------------------------- |
| **accept**                | *enter*                               |
| **abort**                 | *ctrl-c*  *ctrl-g*  *ctrl-q*  *esc*   |
| **beginning-of-line**     | *ctrl-a*  *home*                      |
| **backward-char**         | *ctrl-b* *left*                       |
| **forward-char**          | *ctrl-f*  *right*                     |
| **end-of-line**           | *ctrl-e*  *end*                       |
| **backward-delete-char**  | *ctrl-h*  *bspace*                    |
| **delete-char**           | *del*                                 |
| **up**                    | *ctrl-k*  *ctrl-p*  *up*              |
| **down**                  | *ctrl-j*  *ctrl-n*  *down*            |
| **page-down**             | *pgdn*                                |
| **page-up**               | *pgup*                                |
| **ignore**                |                                       |

### Lazy Mode

[`lazy`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to enable the lazy mode.
If the Lazy mode is enabled, starts the finder only if the candidates are more than one.
If there is only one match returns the only match, if there is no match returns None.

Licence
-------
MIT

Links
-----

* [fzf](https://github.com/junegunn/fzf)
* [ANSI Escape Sequences](https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797)
* [pyte, python terminal emulator](https://github.com/selectel/pyte)
* [Grip, GitHub Readme Instant Preview](https://github.com/joeyespo/grip)
* [Black, The Uncompromising Code Formatter](https://github.com/psf/black)
* [mkdocstrings, Automatic documentation from sources](https://github.com/mkdocstrings/mkdocstrings)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/andreax79/pzp",
    "name": "pzp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "fzf,picker,cli",
    "author": "Andrea Bonomi",
    "author_email": "andrea.bonomi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b6/bc/47484174d7493cd6b5a7fd50803808258557212b289364f73643d3ec8ddd/pzp-0.0.23.tar.gz",
    "platform": "any",
    "description": "pzp\n==============\n\nPure-python fzf-inspired element picker\n\n[![Build Status](https://github.com/andreax79/pzp/workflows/Tests/badge.svg)](https://github.com/andreax79/pzp/actions)\n[![PyPI version](https://badge.fury.io/py/pzp.svg)](https://badge.fury.io/py/pzp)\n[![PyPI](https://img.shields.io/pypi/pyversions/pzp.svg)](https://pypi.org/project/pzp)\n[![Downloads](https://pepy.tech/badge/pzp/month)](https://pepy.tech/project/pzp)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Known Vulnerabilities](https://snyk-widget.herokuapp.com/badge/pip/pzp/badge.svg)](https://snyk.io/test/github/andreax79/pzp)\n[![Documentation](https://readthedocs.org/projects/pzp/badge/?version=latest)](https://pzp.readthedocs.io/en/latest/)\n\nRequirements\n-----------\n* Python 3.6+\n\nInstall\n-------\n\n```\npip install pzp\n```\n\nUsage\n-----\n\n```\nfrom pzp import pzp\npzp(['a', 'b', 'c'])\n```\n\n\n### Layout\n\nThe finder by default starts in fullscreen mode. You can make it start below the\ncursor with [`fullscreen=False`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.\nAlso, with the [`height`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument you can limit the window height.\n\n```python\npzp(candidates=range(0, 1000), fullscreen=False, height=20)\n```\n\n[![asciicast](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ.svg)](https://asciinema.org/a/WtgiYfdtZjlShbeZaHuf5hWCZ?autoplay=1)\n\nYou can choose between the following layout using the [`layout`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) option.\n\n* **default** Display from the bottom of the screen\n* **reverse** Display from the top of the screen\n* **reverse-list** Display from the top of the screen, prompt at the bottom\n\n### Search syntax\n\nThe finder starts in \"extended-search mode\" where you can type in multiple search\nterms delimited by spaces. e.g. `^music .mp3$ sbtrkt !fire`\n\n| Token        | Match type                 | Description                          |\n| ------------ | -------------------------- | ------------------------------------ |\n| `t1 t2`      | tokens-match               | Items that include `t1` and `t2`     |\n| `'star wars` | line-match (not-splitted)  | Items that include `star wars`       |\n| `^music`     | prefix-exact-match         | Items that start with `music`        |\n| `.py$`       | suffix-exact-match         | Items that end with `.py`            |\n| `!fire`      | inverse-exact-match        | Items that do not include `fire`     |\n| `!^music`    | inverse-prefix-exact-match | Items that do not start with `music` |\n| `!.py$`      | inverse-suffix-exact-match | Items that do not end with `.py`     |\n\n### Key/Event Bindings\n\n[`keys_binding`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to bind one or more keys to one action.\nYou can use it to customize key bindings or implementing custom behaviors.\n\n```python\ntry:\n    item = pzp(\n        candidates=candidates,\n        keys_binding={\n            \"custom-action\": [\"ctrl-o\"],\n            \"exclamation\": [\"!\"]\n        },\n    )\n    print(item)\nexcept CustomAction as action:\n    print(action.action)\n    print(action.selected_item)\n```\n\n#### Available Keys\n\n| Key                   | Synonyms type         |\n| --------------------- | --------------------- |\n| space                 |                       |\n| tab                   |                       |\n| btab                  | shift-tab             |\n| enter                 |                       |\n| esc                   |                       |\n| insert                |                       |\n| del                   |                       |\n| bspace                | bs                    |\n| up                    |                       |\n| down                  |                       |\n| left                  |                       |\n| right                 |                       |\n| home                  |                       |\n| end                   |                       |\n| pgdn                  | page-down             |\n| pgup                  | page-up               |\n| f1 - f12              |                       |\n| ctrl-/                |                       |\n| ctrl-\\                |                       |\n| ctrl-]                |                       |\n| ctrl-^                |                       |\n| ctrl-a - ctrl-z       |                       |\n| any single character  |                       |\n\n#### Available Actions\n\nA key can be bound to one of following actions or to a custom action.\n\n| *Action**                 | *Default binding*                     |\n| ------------------------- | ------------------------------------- |\n| **accept**                | *enter*                               |\n| **abort**                 | *ctrl-c*  *ctrl-g*  *ctrl-q*  *esc*   |\n| **beginning-of-line**     | *ctrl-a*  *home*                      |\n| **backward-char**         | *ctrl-b* *left*                       |\n| **forward-char**          | *ctrl-f*  *right*                     |\n| **end-of-line**           | *ctrl-e*  *end*                       |\n| **backward-delete-char**  | *ctrl-h*  *bspace*                    |\n| **delete-char**           | *del*                                 |\n| **up**                    | *ctrl-k*  *ctrl-p*  *up*              |\n| **down**                  | *ctrl-j*  *ctrl-n*  *down*            |\n| **page-down**             | *pgdn*                                |\n| **page-up**               | *pgup*                                |\n| **ignore**                |                                       |\n\n### Lazy Mode\n\n[`lazy`](https://pzp.readthedocs.io/en/latest/api/module/#pzp.pzp) argument allows you to enable the lazy mode.\nIf the Lazy mode is enabled, starts the finder only if the candidates are more than one.\nIf there is only one match returns the only match, if there is no match returns None.\n\nLicence\n-------\nMIT\n\nLinks\n-----\n\n* [fzf](https://github.com/junegunn/fzf)\n* [ANSI Escape Sequences](https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797)\n* [pyte, python terminal emulator](https://github.com/selectel/pyte)\n* [Grip, GitHub Readme Instant Preview](https://github.com/joeyespo/grip)\n* [Black, The Uncompromising Code Formatter](https://github.com/psf/black)\n* [mkdocstrings, Automatic documentation from sources](https://github.com/mkdocstrings/mkdocstrings)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pure-python fzf-inspired element picker",
    "version": "0.0.23",
    "project_urls": {
        "Bug Tracker": "http://github.com/andreax79/pzp/issues",
        "Documentation": "https://pzp.readthedocs.io/en/latest/",
        "Homepage": "http://github.com/andreax79/pzp",
        "Source Code": "http://github.com/andreax79/pzp"
    },
    "split_keywords": [
        "fzf",
        "picker",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c401848b9209329bb52b67cdd1ebf45c27b75e8ff4f49dd066ced3361c826792",
                "md5": "75822ab6aaa3481a922de7a2daab06a4",
                "sha256": "9870f762ca3a89058630d56bcb3fa182cb90aa1fc4ba48d0f03e90fd6cebd17d"
            },
            "downloads": -1,
            "filename": "pzp-0.0.23-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75822ab6aaa3481a922de7a2daab06a4",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 24038,
            "upload_time": "2023-11-13T12:49:08",
            "upload_time_iso_8601": "2023-11-13T12:49:08.928454Z",
            "url": "https://files.pythonhosted.org/packages/c4/01/848b9209329bb52b67cdd1ebf45c27b75e8ff4f49dd066ced3361c826792/pzp-0.0.23-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6bc47484174d7493cd6b5a7fd50803808258557212b289364f73643d3ec8ddd",
                "md5": "dcc86ec3bd9d483928e9fb6f8072343f",
                "sha256": "0d675795bc01903d9341cceee16d2ccfbe2a6621b9f09fa5fca74f1a5aeeffb6"
            },
            "downloads": -1,
            "filename": "pzp-0.0.23.tar.gz",
            "has_sig": false,
            "md5_digest": "dcc86ec3bd9d483928e9fb6f8072343f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 23361,
            "upload_time": "2023-11-13T12:49:10",
            "upload_time_iso_8601": "2023-11-13T12:49:10.519345Z",
            "url": "https://files.pythonhosted.org/packages/b6/bc/47484174d7493cd6b5a7fd50803808258557212b289364f73643d3ec8ddd/pzp-0.0.23.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-13 12:49:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "andreax79",
    "github_project": "pzp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pzp"
}
        
Elapsed time: 0.15752s