Some console tools for inputs and outputs
Project description
PyConsoleIOTools
Installation
pip install consoleiotools # install
pip install --upgrade consoleiotools # update
Get Started
import consoleiotools as cit
print(cit.__version__)
Prints on Screen
>>> cit.start()
*
>>> cit.title('Session Name')
| __SESSION NAME__________________________
>>> cit.echo('Hello World')
| Hello World
>>> cit.echo('Hello World', pre='say')
| (Say) Hello World
>>> cit.ask('Hello World')
| (?) Hello World
>>> cit.info('Hello World')
| (Info) Hello World
>>> cit.warn('Hello World')
| (Warning) Hello World
>>> cit.err('Hello World')
| (Error) Hello World
>>> cit.dim('Hello World')
| Hello World # gray
>>> cit.end()
`
>>> cit.br()
# blank line
>>> cit.br(2)
# blank line
# blank line
Get User Input
>>> cit.get_input()
> Hello World
'Hello World'
>>> cit.get_choice(['Apple', 'Google']) # Enter number to select.
| 1) Apple
| 2) Google
> 2
'Google'
>>> cit.get_choice(['Apple', 'Google']) # Enter string is ok too.
| 1) Apple
| 2) Google
> Google
'Google'
>>> cit.get_choice(['Apple', 'Google'], exitable=True) # Add a choice of exit in menu.
| 0) ** EXIT **
| 1) Apple
| 2) Google
> 0
None
>>> cit.get_choices(['Apple', 'Google']) # Multiple Selection
| 1) [ ] Apple
| 2) [ ] Google
> 1 # Enter number to check or uncheck selections
| 0) ** DONE **
| 1) [+] Apple
| 2) [ ] Google
> Google # Enter string is ok too.
| 0) ** DONE **
| 1) [+] Apple
| 2) [+] Google
> 0 # Enter 0 when done.
['Apple', 'Google'] # return [] is no selections.
>>> cit.get_choices(['Apple', 'Google'], allable=True) # Add a choice of select all in menu.
| 1) [ ] Apple
| 2) [ ] Google
| a) ** ALL **
> a # Enter `a` to check all. If `a` is in choices, enter `all`.
| 0) ** DONE **
| 1) [+] Apple
| 2) [+] Google
| a) ** ALL **
> 0
['Apple', 'Google']
>>> cit.get_choices(['Apple', 'Google'], exitable=True) # Add a choice of exit in menu.
| 0) ** EXIT **
| 1) [ ] Apple
| 2) [ ] Google
> 0
[] # Empty list returned.
File IO
>>> cit.read_file('/path/to/file')
'File contents'
>>> cit.read_file('/path/to/file', with_encoding=True)
('File contents', 'utf-8')
>>> cit.write_file('/path/to/file', 'Contents') # Append content to file.
8 # writed bytes
>>> cit.write_file('/path/to/file', 'Contents', overwrite=True) # Overwrite if file exists.
8 # writed bytes
Controls
>>> cit.pause()
Press Enter to Continue...
>>> cit.bye()
# exit
>>> cit.bye(0)
# exit with code 0
>>> cit.bye('Seeya')
Seeya
# exit
Decorators
@cit.as_session('Hello')
def my_func():
cit.echo('World')
>>> my_func()
*
| __HELLO__________________________
| World
`
@cit.as_session
def underscore_orCamel():
pass
>>> underscore_orCamel()
*
| __UNDERSCORE OR CAMEL__________________________
`
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
consoleiotools-2.8.5.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file consoleiotools-2.8.5.tar.gz.
File metadata
- Download URL: consoleiotools-2.8.5.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a9f22b8c110b3eab54084fa3b5d2e45deb4af2dd4be0eadb5f34ce0dddf403
|
|
| MD5 |
0de289ac8480b148c391e4c4c09b203b
|
|
| BLAKE2b-256 |
1e3244a54227222bd5044cdcd465180518821926b031241a0424e393d3b17845
|
File details
Details for the file consoleiotools-2.8.5-py3-none-any.whl.
File metadata
- Download URL: consoleiotools-2.8.5-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5be812955d8b424bcc722688e7bd57cd5165cea3908d49d85298d0a84bbd612a
|
|
| MD5 |
f3cb75a81082ade5bed675f416a67fa4
|
|
| BLAKE2b-256 |
51cab8fbdcd66d99a0ba62debd21bb9695fb7348aa9e027e8352f311eec3f7a6
|