0.7.9 fix chalk behavior
This commit is contained in:
parent
db49a47ce5
commit
d454eaea2c
5 changed files with 64 additions and 3 deletions
17
CHANGELOG.md
17
CHANGELOG.md
|
|
@ -1,5 +1,22 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.8.2 and 0.7.9
|
||||||
|
|
||||||
|
+ `.color`: fix `chalk` not behaving as expected
|
||||||
|
|
||||||
|
## 0.8.1 and 0.7.8
|
||||||
|
|
||||||
|
+ Fix missing type guard in `unbound_fk()` and `bound_fk()`
|
||||||
|
|
||||||
|
## 0.8.0
|
||||||
|
|
||||||
|
+ Add `username_column()` to `.sqlalchemy`
|
||||||
|
+ Improve (experimental) `Waiter`
|
||||||
|
|
||||||
|
## 0.7.7
|
||||||
|
|
||||||
|
+ Fix imports in `.sqlalchemy`
|
||||||
|
|
||||||
## 0.7.5
|
## 0.7.5
|
||||||
|
|
||||||
+ Delay release of `FakeModule` to 0.9.0
|
+ Delay release of `FakeModule` to 0.9.0
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ license = "Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"suou==0.7.8",
|
"suou==0.7.9",
|
||||||
"itsdangerous",
|
"itsdangerous",
|
||||||
"toml",
|
"toml",
|
||||||
"pydantic",
|
"pydantic",
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ from .strtools import PrefixIdentifier
|
||||||
from .validators import matches
|
from .validators import matches
|
||||||
from .redact import redact_url_password
|
from .redact import redact_url_password
|
||||||
from .http import WantsContentType
|
from .http import WantsContentType
|
||||||
from .color import chalk
|
from .color import chalk, WebColor
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = "0.7.9"
|
||||||
|
|
||||||
__version__ = "0.7.8"
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue',
|
'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue',
|
||||||
|
|
@ -45,6 +47,7 @@ __all__ = (
|
||||||
'MissingConfigError', 'MissingConfigWarning', 'PrefixIdentifier',
|
'MissingConfigError', 'MissingConfigWarning', 'PrefixIdentifier',
|
||||||
'Siq', 'SiqCache', 'SiqGen', 'SiqType', 'Snowflake', 'SnowflakeGen',
|
'Siq', 'SiqCache', 'SiqGen', 'SiqType', 'Snowflake', 'SnowflakeGen',
|
||||||
'StringCase', 'TimedDict', 'TomlI18n', 'UserSigner', 'Wanted', 'WantsContentType',
|
'StringCase', 'TimedDict', 'TomlI18n', 'UserSigner', 'Wanted', 'WantsContentType',
|
||||||
|
'WebColor',
|
||||||
'addattr', 'additem', 'age_and_days', 'alru_cache', 'b2048decode', 'b2048encode',
|
'addattr', 'additem', 'age_and_days', 'alru_cache', 'b2048decode', 'b2048encode',
|
||||||
'b32ldecode', 'b32lencode', 'b64encode', 'b64decode', 'cb32encode',
|
'b32ldecode', 'b32lencode', 'b64encode', 'b64decode', 'cb32encode',
|
||||||
'cb32decode', 'chalk', 'count_ones', 'dei_args', 'deprecated',
|
'cb32decode', 'chalk', 'count_ones', 'dei_args', 'deprecated',
|
||||||
|
|
|
||||||
|
|
@ -55,24 +55,34 @@ class Chalk:
|
||||||
return Chalk(self._flags + (beg,), self._ends + (end,))
|
return Chalk(self._flags + (beg,), self._ends + (end,))
|
||||||
def __call__(self, s: str) -> str:
|
def __call__(self, s: str) -> str:
|
||||||
return ''.join(self._flags) + s + ''.join(reversed(self._ends))
|
return ''.join(self._flags) + s + ''.join(reversed(self._ends))
|
||||||
|
@property
|
||||||
def red(self):
|
def red(self):
|
||||||
return self._wrap(self.RED, self.END_COLOR)
|
return self._wrap(self.RED, self.END_COLOR)
|
||||||
|
@property
|
||||||
def green(self):
|
def green(self):
|
||||||
return self._wrap(self.GREEN, self.END_COLOR)
|
return self._wrap(self.GREEN, self.END_COLOR)
|
||||||
|
@property
|
||||||
def blue(self):
|
def blue(self):
|
||||||
return self._wrap(self.BLUE, self.END_COLOR)
|
return self._wrap(self.BLUE, self.END_COLOR)
|
||||||
|
@property
|
||||||
def yellow(self):
|
def yellow(self):
|
||||||
return self._wrap(self.YELLOW, self.END_COLOR)
|
return self._wrap(self.YELLOW, self.END_COLOR)
|
||||||
|
@property
|
||||||
def cyan(self):
|
def cyan(self):
|
||||||
return self._wrap(self.CYAN, self.END_COLOR)
|
return self._wrap(self.CYAN, self.END_COLOR)
|
||||||
|
@property
|
||||||
def purple(self):
|
def purple(self):
|
||||||
return self._wrap(self.PURPLE, self.END_COLOR)
|
return self._wrap(self.PURPLE, self.END_COLOR)
|
||||||
|
@property
|
||||||
def grey(self):
|
def grey(self):
|
||||||
return self._wrap(self.GREY, self.END_COLOR)
|
return self._wrap(self.GREY, self.END_COLOR)
|
||||||
gray = grey
|
gray = grey
|
||||||
marine = blue
|
marine = blue
|
||||||
|
magenta = purple
|
||||||
|
@property
|
||||||
def bold(self):
|
def bold(self):
|
||||||
return self._wrap(self.BOLD, self.END_BOLD)
|
return self._wrap(self.BOLD, self.END_BOLD)
|
||||||
|
@property
|
||||||
def faint(self):
|
def faint(self):
|
||||||
return self._wrap(self.FAINT, self.END_BOLD)
|
return self._wrap(self.FAINT, self.END_BOLD)
|
||||||
|
|
||||||
|
|
@ -130,3 +140,7 @@ class WebColor(namedtuple('_WebColor', 'red green blue')):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"rgb({self.red}, {self.green}, {self.blue})"
|
return f"rgb({self.red}, {self.green}, {self.blue})"
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ('chalk', 'WebColor')
|
||||||
|
|
||||||
|
|
|
||||||
27
tests/test_color.py
Normal file
27
tests/test_color.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from suou import chalk
|
||||||
|
|
||||||
|
class TestColor(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
...
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def test_chalk_colors(self):
|
||||||
|
strg = "The quick brown fox jumps over the lazy dog"
|
||||||
|
|
||||||
|
self.assertEqual(f'\x1b[31m{strg}\x1b[39m', chalk.red(strg))
|
||||||
|
self.assertEqual(f'\x1b[32m{strg}\x1b[39m', chalk.green(strg))
|
||||||
|
self.assertEqual(f'\x1b[34m{strg}\x1b[39m', chalk.blue(strg))
|
||||||
|
self.assertEqual(f'\x1b[36m{strg}\x1b[39m', chalk.cyan(strg))
|
||||||
|
self.assertEqual(f'\x1b[33m{strg}\x1b[39m', chalk.yellow(strg))
|
||||||
|
self.assertEqual(f'\x1b[35m{strg}\x1b[39m', chalk.purple(strg))
|
||||||
|
|
||||||
|
def test_chalk_bold(self):
|
||||||
|
strg = "The quick brown fox jumps over the lazy dog"
|
||||||
|
self.assertEqual(f'\x1b[1m{strg}\x1b[22m', chalk.bold(strg))
|
||||||
|
self.assertEqual(f'\x1b[2m{strg}\x1b[22m', chalk.faint(strg))
|
||||||
|
self.assertEqual(f'\x1b[1m\x1b[33m{strg}\x1b[39m\x1b[22m', chalk.bold.yellow(strg))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue