diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-readchar.spec | 481 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 483 insertions, 0 deletions
@@ -0,0 +1 @@ +/readchar-4.0.5.tar.gz diff --git a/python-readchar.spec b/python-readchar.spec new file mode 100644 index 0000000..121cd31 --- /dev/null +++ b/python-readchar.spec @@ -0,0 +1,481 @@ +%global _empty_manifest_terminate_build 0 +Name: python-readchar +Version: 4.0.5 +Release: 1 +Summary: Library to easily read single chars and key strokes +License: MIT +URL: https://github.com/magmax/python-readchar +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a1/57/439aaa28659e66265518232bf4291ae5568aa01cd9e0e0f6f8fe3b300e9e/readchar-4.0.5.tar.gz +BuildArch: noarch + +Requires: python3-setuptools + +%description +[](https://github.com/magmax/python-readchar) +[](https://pypi.python.org/pypi/readchar) +[](https://pypi.python.org/pypi/readchar) +[](LICENCE) <br> +[](https://github.com/magmax/python-readchar/actions/workflows/run-tests.yaml?query=branch%3Amaster) +[](https://coveralls.io/github/magmax/python-readchar?branch=master) +[](https://pypi.python.org/pypi/readchar) + +# python-readchar + +Library to easily read single chars and keystrokes. + +Born as a [python-inquirer](https://github.com/magmax/python-inquirer) requirement. + +## Installation + +simply install it via `pip`: + +```bash +pip install readchar +``` + +Or download the source code from [PyPi](https://pypi.python.org/pypi/readchar). + +## Usage + +Simply read a character or keystroke: + +```python +import readchar + +key = readchar.readkey() +``` + +React to different kinds of key-presses: + +```python +from readchar import readkey, key + +while True: + k = readkey() + if k == "a": + # do stuff + if k == key.DOWN: + # do stuff + if k == key.ENTER: + break +``` + +## Documentation + +There are just two methods: + +### `readchar.readchar() -> str` + +Reads one character from `stdin`, returning it as a string with length 1. Waits until a +character is available. + +As only ASCII characters are actually a single character, you usually want to use the +next function, that also handles longer keys. + +### `readchar.readkey() -> str` + +Reads the next keystroke from `stdin`, returning it as a string. Waits until a keystroke +is available. + +A keystroke can be: + +- single characters as returned by `readchar()`. These include: + - character for normal keys: <kbd>a</kbd>, <kbd>Z</kbd>, <kbd>9</kbd>,... + - special characters like <kbd>ENTER</kbd>, <kbd>BACKSPACE</kbd>, <kbd>TAB</kbd>,... + - combinations with <kbd>CTRL</kbd>: <kbd>CTRL</kbd>+<kbd>A</kbd>,... +- keys that are made up of multiple characters: + - characters for cursors/arrows: <kbd>🡩</kbd>, <kbd>🡪</kbd>, <kbd>🡫</kbd>, + <kbd>🡨</kbd> + - navigation keys: <kbd>INSERT</kbd>, <kbd>HOME</kbd>,... + - function keys: <kbd>F1</kbd> to <kbd>F12</kbd> + - combinations with <kbd>ALT</kbd>: <kbd>ALT</kbd>+<kbd>A</kbd>,... + - combinations with <kbd>CTRL</kbd> and <kbd>ALT</kbd>: + <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>SUPR</kbd>,... + +> **Note** <kbd>CTRL</kbd>+<kbd>C</kbd> will not be returned by `readkey()`, but instead +> raise a `KeyboardInterupt`. If you what to handle it yourself, use `readchar()`. + +### `readchar.key` module + +This submodule contains a list of available keys to compare against. The constants are +defined depending on your operating system, so it should be fully portable. If a key is +listed here for your platform, `readkey()` can read it, and you can compare against it. + +### `readchar.config` class + +This static class contains configurations for `readchar`. It holds constants that are +used in other parts of the code as class attributes. You can override/change these to +modify its behaviour. Here is a description of the existing attributes: + +<dl> +<dt><code>INTERRUPT_KEYS</code></dt> +<dd> + +List of keys that will result in `readkey()` raising a `KeyboardInterrupt`. <br> +*Default:* `[key.CTRL_C]` + +</dd> +</dl> + +## OS Support + +This library actively supports these operating systems: + +- Linux +- Windows + +Some operating systems are enabled, but not actively tested or supported: + +- macOS +- FreeBSD / OpenBSD + +Theoretically every Unix based system should work, but they will not be actively tested. +It is also required that somebody provides initial test results before the OS is enabled +and added to the list. Feel free to open a PR for that. + +Thank you! + +## How to contribute + +You have an issue problem or found a bug? You have a great new idea or just want to fix +a typo? Great :+1:. We are happy to accept your issue or pull request, but first, please +read our +[contribution guidelines](https://github.com/magmax/python-readchar/blob/master/CONTRIBUTING.md). +They will also tell you how to write code for this repo and how to properly prepare an +issue or a pull request. + +______________________________________________________________________ + +*Copyright (c) 2014-2022 Miguel Ángel García* + + +%package -n python3-readchar +Summary: Library to easily read single chars and key strokes +Provides: python-readchar +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-readchar +[](https://github.com/magmax/python-readchar) +[](https://pypi.python.org/pypi/readchar) +[](https://pypi.python.org/pypi/readchar) +[](LICENCE) <br> +[](https://github.com/magmax/python-readchar/actions/workflows/run-tests.yaml?query=branch%3Amaster) +[](https://coveralls.io/github/magmax/python-readchar?branch=master) +[](https://pypi.python.org/pypi/readchar) + +# python-readchar + +Library to easily read single chars and keystrokes. + +Born as a [python-inquirer](https://github.com/magmax/python-inquirer) requirement. + +## Installation + +simply install it via `pip`: + +```bash +pip install readchar +``` + +Or download the source code from [PyPi](https://pypi.python.org/pypi/readchar). + +## Usage + +Simply read a character or keystroke: + +```python +import readchar + +key = readchar.readkey() +``` + +React to different kinds of key-presses: + +```python +from readchar import readkey, key + +while True: + k = readkey() + if k == "a": + # do stuff + if k == key.DOWN: + # do stuff + if k == key.ENTER: + break +``` + +## Documentation + +There are just two methods: + +### `readchar.readchar() -> str` + +Reads one character from `stdin`, returning it as a string with length 1. Waits until a +character is available. + +As only ASCII characters are actually a single character, you usually want to use the +next function, that also handles longer keys. + +### `readchar.readkey() -> str` + +Reads the next keystroke from `stdin`, returning it as a string. Waits until a keystroke +is available. + +A keystroke can be: + +- single characters as returned by `readchar()`. These include: + - character for normal keys: <kbd>a</kbd>, <kbd>Z</kbd>, <kbd>9</kbd>,... + - special characters like <kbd>ENTER</kbd>, <kbd>BACKSPACE</kbd>, <kbd>TAB</kbd>,... + - combinations with <kbd>CTRL</kbd>: <kbd>CTRL</kbd>+<kbd>A</kbd>,... +- keys that are made up of multiple characters: + - characters for cursors/arrows: <kbd>🡩</kbd>, <kbd>🡪</kbd>, <kbd>🡫</kbd>, + <kbd>🡨</kbd> + - navigation keys: <kbd>INSERT</kbd>, <kbd>HOME</kbd>,... + - function keys: <kbd>F1</kbd> to <kbd>F12</kbd> + - combinations with <kbd>ALT</kbd>: <kbd>ALT</kbd>+<kbd>A</kbd>,... + - combinations with <kbd>CTRL</kbd> and <kbd>ALT</kbd>: + <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>SUPR</kbd>,... + +> **Note** <kbd>CTRL</kbd>+<kbd>C</kbd> will not be returned by `readkey()`, but instead +> raise a `KeyboardInterupt`. If you what to handle it yourself, use `readchar()`. + +### `readchar.key` module + +This submodule contains a list of available keys to compare against. The constants are +defined depending on your operating system, so it should be fully portable. If a key is +listed here for your platform, `readkey()` can read it, and you can compare against it. + +### `readchar.config` class + +This static class contains configurations for `readchar`. It holds constants that are +used in other parts of the code as class attributes. You can override/change these to +modify its behaviour. Here is a description of the existing attributes: + +<dl> +<dt><code>INTERRUPT_KEYS</code></dt> +<dd> + +List of keys that will result in `readkey()` raising a `KeyboardInterrupt`. <br> +*Default:* `[key.CTRL_C]` + +</dd> +</dl> + +## OS Support + +This library actively supports these operating systems: + +- Linux +- Windows + +Some operating systems are enabled, but not actively tested or supported: + +- macOS +- FreeBSD / OpenBSD + +Theoretically every Unix based system should work, but they will not be actively tested. +It is also required that somebody provides initial test results before the OS is enabled +and added to the list. Feel free to open a PR for that. + +Thank you! + +## How to contribute + +You have an issue problem or found a bug? You have a great new idea or just want to fix +a typo? Great :+1:. We are happy to accept your issue or pull request, but first, please +read our +[contribution guidelines](https://github.com/magmax/python-readchar/blob/master/CONTRIBUTING.md). +They will also tell you how to write code for this repo and how to properly prepare an +issue or a pull request. + +______________________________________________________________________ + +*Copyright (c) 2014-2022 Miguel Ángel García* + + +%package help +Summary: Development documents and examples for readchar +Provides: python3-readchar-doc +%description help +[](https://github.com/magmax/python-readchar) +[](https://pypi.python.org/pypi/readchar) +[](https://pypi.python.org/pypi/readchar) +[](LICENCE) <br> +[](https://github.com/magmax/python-readchar/actions/workflows/run-tests.yaml?query=branch%3Amaster) +[](https://coveralls.io/github/magmax/python-readchar?branch=master) +[](https://pypi.python.org/pypi/readchar) + +# python-readchar + +Library to easily read single chars and keystrokes. + +Born as a [python-inquirer](https://github.com/magmax/python-inquirer) requirement. + +## Installation + +simply install it via `pip`: + +```bash +pip install readchar +``` + +Or download the source code from [PyPi](https://pypi.python.org/pypi/readchar). + +## Usage + +Simply read a character or keystroke: + +```python +import readchar + +key = readchar.readkey() +``` + +React to different kinds of key-presses: + +```python +from readchar import readkey, key + +while True: + k = readkey() + if k == "a": + # do stuff + if k == key.DOWN: + # do stuff + if k == key.ENTER: + break +``` + +## Documentation + +There are just two methods: + +### `readchar.readchar() -> str` + +Reads one character from `stdin`, returning it as a string with length 1. Waits until a +character is available. + +As only ASCII characters are actually a single character, you usually want to use the +next function, that also handles longer keys. + +### `readchar.readkey() -> str` + +Reads the next keystroke from `stdin`, returning it as a string. Waits until a keystroke +is available. + +A keystroke can be: + +- single characters as returned by `readchar()`. These include: + - character for normal keys: <kbd>a</kbd>, <kbd>Z</kbd>, <kbd>9</kbd>,... + - special characters like <kbd>ENTER</kbd>, <kbd>BACKSPACE</kbd>, <kbd>TAB</kbd>,... + - combinations with <kbd>CTRL</kbd>: <kbd>CTRL</kbd>+<kbd>A</kbd>,... +- keys that are made up of multiple characters: + - characters for cursors/arrows: <kbd>🡩</kbd>, <kbd>🡪</kbd>, <kbd>🡫</kbd>, + <kbd>🡨</kbd> + - navigation keys: <kbd>INSERT</kbd>, <kbd>HOME</kbd>,... + - function keys: <kbd>F1</kbd> to <kbd>F12</kbd> + - combinations with <kbd>ALT</kbd>: <kbd>ALT</kbd>+<kbd>A</kbd>,... + - combinations with <kbd>CTRL</kbd> and <kbd>ALT</kbd>: + <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>SUPR</kbd>,... + +> **Note** <kbd>CTRL</kbd>+<kbd>C</kbd> will not be returned by `readkey()`, but instead +> raise a `KeyboardInterupt`. If you what to handle it yourself, use `readchar()`. + +### `readchar.key` module + +This submodule contains a list of available keys to compare against. The constants are +defined depending on your operating system, so it should be fully portable. If a key is +listed here for your platform, `readkey()` can read it, and you can compare against it. + +### `readchar.config` class + +This static class contains configurations for `readchar`. It holds constants that are +used in other parts of the code as class attributes. You can override/change these to +modify its behaviour. Here is a description of the existing attributes: + +<dl> +<dt><code>INTERRUPT_KEYS</code></dt> +<dd> + +List of keys that will result in `readkey()` raising a `KeyboardInterrupt`. <br> +*Default:* `[key.CTRL_C]` + +</dd> +</dl> + +## OS Support + +This library actively supports these operating systems: + +- Linux +- Windows + +Some operating systems are enabled, but not actively tested or supported: + +- macOS +- FreeBSD / OpenBSD + +Theoretically every Unix based system should work, but they will not be actively tested. +It is also required that somebody provides initial test results before the OS is enabled +and added to the list. Feel free to open a PR for that. + +Thank you! + +## How to contribute + +You have an issue problem or found a bug? You have a great new idea or just want to fix +a typo? Great :+1:. We are happy to accept your issue or pull request, but first, please +read our +[contribution guidelines](https://github.com/magmax/python-readchar/blob/master/CONTRIBUTING.md). +They will also tell you how to write code for this repo and how to properly prepare an +issue or a pull request. + +______________________________________________________________________ + +*Copyright (c) 2014-2022 Miguel Ángel García* + + +%prep +%autosetup -n readchar-4.0.5 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-readchar -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 4.0.5-1 +- Package Spec generated @@ -0,0 +1 @@ +973c1a67bdbb4cd5e206c5b50f4dbde4 readchar-4.0.5.tar.gz |