Adding upstream version 0.3.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
b63ff22698
commit
436c868283
11 changed files with 233 additions and 0 deletions
31
.github/workflows/pythonpublish.yml
vendored
Normal file
31
.github/workflows/pythonpublish.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# This workflows will upload a Python Package using Twine when a release is created
|
||||||
|
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
||||||
|
|
||||||
|
name: Upload Python Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install setuptools wheel twine
|
||||||
|
- name: Build and publish
|
||||||
|
env:
|
||||||
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
||||||
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
twine upload dist/*
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.pyc
|
||||||
|
__pycache__/
|
1
CHANGES
Normal file
1
CHANGES
Normal file
|
@ -0,0 +1 @@
|
||||||
|
2015.11.16: Initial release
|
7
LICENSE
Normal file
7
LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Copyright (c) 2015 Nagarjuna Kumarappan
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
5
MANIFEST.in
Normal file
5
MANIFEST.in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
include VERSION
|
||||||
|
include README.md
|
||||||
|
include CHANGES
|
||||||
|
recursive-include pyfzf *
|
||||||
|
|
52
README.md
Normal file
52
README.md
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
pyfzf
|
||||||
|
=====
|
||||||
|
|
||||||
|
![](https://img.shields.io/badge/license-MIT-green.svg?style=flat)
|
||||||
|
![https://pypi.python.org/pypi/pyfzf](https://img.shields.io/pypi/dm/pyfzf.svg?style=flat)
|
||||||
|
|
||||||
|
##### A python wrapper for *junegunn*'s awesome [fzf](https://github.com/junegunn/fzf).
|
||||||
|
|
||||||
|
![](https://raw.githubusercontent.com/nk412/pyfzf/master/pyfzf.gif)
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Python 3.6+
|
||||||
|
* [fzf](https://github.com/junegunn/fzf)
|
||||||
|
|
||||||
|
*Note*: fzf must be installed and available on PATH.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
pip install pyfzf
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
>>> from pyfzf.pyfzf import FzfPrompt
|
||||||
|
>>> fzf = FzfPrompt()
|
||||||
|
|
||||||
|
If `fzf` is not available on PATH, you can specify a location
|
||||||
|
|
||||||
|
>>> fzf = FzfPrompt('/path/to/fzf')
|
||||||
|
|
||||||
|
Simply pass a list of options to the prompt function to invoke fzf.
|
||||||
|
|
||||||
|
>>> fzf.prompt(range(0,10))
|
||||||
|
|
||||||
|
You can pass additional arguments to fzf as a second argument
|
||||||
|
|
||||||
|
>>> fzf.prompt(range(0,10), '--multi --cycle')
|
||||||
|
|
||||||
|
Input items are written to a temporary file which is then passed to fzf.
|
||||||
|
The items are delimited with `\n` by default, you can also change the delimiter
|
||||||
|
(useful for multiline items)
|
||||||
|
|
||||||
|
>>> fzf.prompt(range(0,10), '--read0', '\0')
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
MIT
|
||||||
|
|
||||||
|
Thanks
|
||||||
|
------
|
||||||
|
@brookite for adding Windows support in v0.3.0
|
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0.3.1
|
BIN
pyfzf.gif
Normal file
BIN
pyfzf.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
6
pyfzf/__init__.py
Normal file
6
pyfzf/__init__.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
__author__ = 'Nagarjuna Kumarappan (nagarjuna.412@gmail.com)'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__version__ = '0.3.1'
|
||||||
|
|
||||||
|
|
||||||
|
from .pyfzf import *
|
67
pyfzf/pyfzf.py
Executable file
67
pyfzf/pyfzf.py
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# coding: utf-8
|
||||||
|
# Copyright (c) 2022 Nagarjuna Kumarappan
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# Author: Nagarjuna Kumarappan <nagarjuna.412@gmail.com>
|
||||||
|
|
||||||
|
from shutil import which
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
# constants
|
||||||
|
FZF_URL = "https://github.com/junegunn/fzf"
|
||||||
|
|
||||||
|
|
||||||
|
class FzfPrompt:
|
||||||
|
def __init__(self, executable_path=None):
|
||||||
|
if executable_path:
|
||||||
|
self.executable_path = executable_path
|
||||||
|
elif not which("fzf") and not executable_path:
|
||||||
|
raise SystemError(
|
||||||
|
f"Cannot find 'fzf' installed on PATH. ({FZF_URL})")
|
||||||
|
else:
|
||||||
|
self.executable_path = "fzf"
|
||||||
|
|
||||||
|
def prompt(self, choices=None, fzf_options="", delimiter='\n'):
|
||||||
|
# convert lists to strings [ 1, 2, 3 ] => "1\n2\n3"
|
||||||
|
choices_str = delimiter.join(map(str, choices))
|
||||||
|
selection = []
|
||||||
|
|
||||||
|
with tempfile.NamedTemporaryFile(delete=False) as input_file:
|
||||||
|
with tempfile.NamedTemporaryFile(delete=False) as output_file:
|
||||||
|
# Create an temp file with list entries as lines
|
||||||
|
input_file.write(choices_str.encode('utf-8'))
|
||||||
|
input_file.flush()
|
||||||
|
|
||||||
|
# Invoke fzf externally and write to output file
|
||||||
|
os.system(
|
||||||
|
f"{self.executable_path} {fzf_options} < \"{input_file.name}\" > \"{output_file.name}\"")
|
||||||
|
|
||||||
|
# get selected options
|
||||||
|
with open(output_file.name, encoding="utf-8") as f:
|
||||||
|
for line in f:
|
||||||
|
selection.append(line.strip('\n'))
|
||||||
|
|
||||||
|
os.unlink(input_file.name)
|
||||||
|
os.unlink(output_file.name)
|
||||||
|
|
||||||
|
return selection
|
61
setup.py
Executable file
61
setup.py
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# coding: utf-8
|
||||||
|
# Copyright (c) 2015 Nagarjuna Kumarappan
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# Author: Nagarjuna Kumarappan <nagarjuna.412@gmail.com>
|
||||||
|
|
||||||
|
import os
|
||||||
|
from setuptools import setup
|
||||||
|
from distutils.command.install import INSTALL_SCHEMES
|
||||||
|
|
||||||
|
for scheme in INSTALL_SCHEMES.values():
|
||||||
|
scheme['data'] = scheme['purelib']
|
||||||
|
|
||||||
|
prjdir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
def read(filename):
|
||||||
|
return open(os.path.join(prjdir, filename)).read()
|
||||||
|
|
||||||
|
LONG_DESC = read('README.md') + '\nCHANGES\n=======\n\n' + read('CHANGES')
|
||||||
|
|
||||||
|
setup(name='pyfzf',
|
||||||
|
include_package_data=True,
|
||||||
|
version=read('VERSION').strip('\n'),
|
||||||
|
description="Python wrapper for junegunn's fuzzyfinder (fzf)",
|
||||||
|
long_description=LONG_DESC,
|
||||||
|
author='Nagarjuna Kumarappan',
|
||||||
|
license='MIT',
|
||||||
|
author_email='nagarjuna.412@gmail.com',
|
||||||
|
url='https://github.com/nk412/pyfzf',
|
||||||
|
install_requires=[],
|
||||||
|
py_modules=['pyfzf'],
|
||||||
|
packages=['pyfzf'],
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 4 - Beta',
|
||||||
|
'Environment :: Console',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Operating System :: OS Independent',
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Topic :: Terminals'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue