PyMsgPrompt
PyMsgPrompt is a python module to embed prompt functionality in your code.
Version
The current version of this module is 1.3.0 and this is the third BETA release after first BETA version 1.2.2, however, you can run the below command to check the version of the module.
python -m pymsgprompt.version
Platform Supports
This is a cross platform module and supported both in python 2 and 3.
Installation
To install this module you can use clone with git or just simply run pip install command.
Using git
git clone https://github.com/antaripchatterjee/PyMsgPrompt.git
cd PyMsgPrompt
python setup.py install
Using pip
pip install pymsgprompt
Uninstallation
Uninstallation can be done by running pip uninstall command.
pip uninstall pymsgpropmt
Usage
To test this module, you can run the below simple code.
from pymsgprompt.prompt import ask, log
from pymsgprompt.logger import perror, pinfo, pwarn
import time
if __name__ == '__main__':
answer = ask('Do you want to close?', choices=['yes', 'no', 'not sure'], default='yes', timestamp=True, regexp=True, ignore_case=False)
# with open('test.txt', 'w') as test:
# print (log('Answer is %s'%answer, logtype='error', timestamp=True, file=test))
if answer.startswith('n'):
log('Answer is %s'%answer, logtype='error', timestamp=False, reset=True)
else:
log('Answer is %s'%answer, logtype='info', timestamp=False, reset=True)
for i in range(1000, 0, -1):
log('The message is %d'%i, timestamp=True, end=None if i > 1 else '\n', reset=i==1)
time.sleep(0.01)
pinfo('I am a Python Developer')
pwarn('Some kind of warning message')
perror('Some kind of error message')
Below is the output,
[QUES] 2021-Apr-01 22:27:50: Do you want to close? (yes/ no/ not sure)[yes]not
not sure
Answer is not sure
[INFO] 2021-Apr-01 22:28:11: The message is 1
[INFO] 2021-Apr-01 22:28:11: I am a Python Developer
[WARN] 2021-Apr-01 22:28:11: Some kind of warning message
[ERROR] 2021-Apr-01 22:28:11: Some kind of error message
API Reference
pymsgprompt.prompt.ask function takes two positional arguments on_success and on_error, and they expect two callback functions, which will be called after validating the answer. The default value of them are pymsgprompt.handler.default_on_success and pymsgprompt.handler.default_on_error respectively.
The callback function for on_success takes three arguments, which are question, actual_answer and original_answer. The ask function returns the same value, actually returned by the callback function. The default function returns the original_answer.
The callback function for on_error takes four arguments, which are question, choices, default, and error. This value must return either True, means the question should be reasked, or False, means no need to ask the question again. The default function returns the False.
A good documentation, specially for the developers, will be provided later.
License
This module is licensed under MIT License.
Contribution
Pull requests are always awesome, but please make sure of raising request, before making any changes.
Metadata
Release files for PyMsgPrompt 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyMsgPrompt-1.3.0.tar.gz | 7.5 kB | Without provenance | Details for PyMsgPrompt-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyMsgPrompt-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for PyMsgPrompt-1.3.0-py3-none-any.whl |
Total release size: 15.3 kB
Release files / PyMsgPrompt-1.3.0.tar.gz
| Download URL | PyMsgPrompt-1.3.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7da7032f87aa51d8fb360430bf6e5a605430fd85a6283f56cb02d5f5d7ef852
|
|
BLAKE2b-256 checksum How to use checksums |
3dd997df6a117cb523427f9c78b4140d5db689bc7bc9a59b11b7f098cfb9c1b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
|
Release files / PyMsgPrompt-1.3.0-py3-none-any.whl
| Download URL | PyMsgPrompt-1.3.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b496785c6aaf115756ef2eb4904463b0b3c44840515c2f99d3daa6fdb9b2064
|
|
BLAKE2b-256 checksum How to use checksums |
eab086e8dbe340631a6da605170d92f2889a14ad141b30bed8cd5075196b718c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
|
Security for PyMsgPrompt 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.