afmt
This module provides an easy way to format text in CLI environment.
It is designed for use in f-strings but regular string formatting with
format method is also supported.
The module takes care of stripping ANSI escape sequences from piped output and puts the sequences only if they're supported by the output device.
Setup
$ pip install afmt
Usage and examples
from afmt import Formatter
f = Formatter()
# You can use inline styling
print(f'{f:bold}bold text{f:e}')
# You can define specs outside of an f-string
warning = 'bold bg(yellow) fg(black) italic'
error = 'bold bg(red) fg(white) underline'
print(f'{f:{warning}}Warning: you shouldn\'t do it{f:e}')
print(f'{f:{error}}Error: you can\'t do it{f:e}')
# You can define custom styles in the formatter instance
f.add_style('important', 'b fg(red)')
print(f'{f:important}important text{f:e}')
# Or you can pass a dict of styles in the initializer
f = Formatter(styles={
'important': 'bold fg(255,0,0)',
'unimporant': 'faint'
})
print(f'{f:important}important text{f:e}')
print(f'{f:unimportant}not so important text{f:e}')
# Move cursor to 4th row and 6th column and print text in reverse video mode
print(f'{f:reverse goto(4,6)}hello, world{f:e}')
# Make text bold and underlined and unset bold in the middle
print(f'{f:bold italic}hello,{f:!bold} world{f:e}')
Development status
This module is in the early stage of development. More features are coming hopefully soon.
Metadata
Release files for afmt 0.0.5
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 |
|---|---|---|---|---|
| afmt-0.0.5.tar.gz | 4.3 kB | Without provenance | Details for afmt-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| afmt-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for afmt-0.0.5-py3-none-any.whl |
Total release size: 9.8 kB
Release files / afmt-0.0.5.tar.gz
| Download URL | afmt-0.0.5.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25585bbe199291a818e7e2082217dcb7e52a8127451c24afc80c971139bf5e39
|
|
BLAKE2b-256 checksum How to use checksums |
059ade8aa0efa397f3f1cb0a965f929cdd6855755176465b45f6bff2d4b3d80d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / afmt-0.0.5-py3-none-any.whl
| Download URL | afmt-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58755892581134fc4ed99d0f65c45d54cfc403e42bb22cbdc880a85315dcd8f3
|
|
BLAKE2b-256 checksum How to use checksums |
b2d86a50e1de2f727a5c214882e88a499a5d0b33a5149592583868529f8ed664
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for afmt 0.0.5
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.