Simple Chalk
Note: This document is best viewed on github. Pypi's headers are all caps which presents inaccurate information"
Table of Contents
Intro
What is it?
A terminal string styling library for python. It implements a subset of Sindre Sorhus' chalk (which is for js).
e.g. chalk.green.bold("success") prints like you'd expect in the console.
Why create it?
I am familiar with and enjoy the syntax of chalk. Anthonyalmarza's chalk deviates from that syntax and so I created my own.
I'm also new to python so this was a good way to learn.
Why the subset of features?
I only use chalk for very simple purposes so I left out things like 256 colors.
Install
$ pip install simple_chalk
Usage
from simple_chalk import chalk, green
# both of these are the same
print(chalk.green("success"))
print(green("success"))
# chained
print(green.bold("success"))
# assign combinations
success = green.bold.underline
print(success("we did it!"))
# last color wins
print(green.red("this is red"))
# background and foreground colors are separate
whyNot = green.bgWhite.red.bgGray
print(whyNot("this is red text with a gray background"))
Api
simple_chalk exports the following
chalk (string) => string
- A singleton that can be used instead of importing the colors and styles directly.
chalkand all exported colors/styles are chainable callables. When called, they take a single string argument and return a string wrapped in the appropriate ascii color codes.
newChalk () => Chalk
- You probably don't need this, but it creates a new chalk instance in case another library is misbehaving.
The following colors are exported
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- blackBright (also 'gray' and 'grey')
- redBright
- greenBright
- yellowBright
- blueBright
- magentaBright
- cyanBright
- whiteBright
Each color also has a camel-cased bg equivalent. e.g. bgBlack
and bgYellowBright
Finally the following miscellaneous styles are exported
- bold
- dim
- underline
- hidden
Test
hub clone olsonpm/py_simple-chalk
cd py_simple-chalk
python runTests.py
Features included from js version of Chalk
- chainable api
- same color names (with added aliases)
Features omitted
** Features marked with * are ones I'd pull in should someone create a PR.
- 256 colors and TrueColor support
- multiple arguments, and thus nested styles
- *color support detection
- *blue -> blueBright auto conversion on windows
- *ability to disable
- *modifiers other than the miscellaneous styles noted above.
e.g.
reset,italic,inverseetc.
Metadata
Release files for simple-chalk 0.1.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 |
|---|---|---|---|---|
| simple_chalk-0.1.0.tar.gz | 13.9 kB | Without provenance | Details for simple_chalk-0.1.0.tar.gz |
Release files / simple_chalk-0.1.0.tar.gz
| Download URL | simple_chalk-0.1.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d80f55993dfa040c1b55d2fbfb925e4fbb5798c2934601aa448ef4a192d84196
|
|
BLAKE2b-256 checksum How to use checksums |
3197b8114a347aee340570eb92b1a1fe512a038766903af7aa4e28447dc25c80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for simple-chalk 0.1.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.