From 4f1da48b3d3adac3efc901c8fd79d623e6bc6ced Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Sat, 15 Aug 2026 18:30:43 +1000 Subject: [PATCH 1/2] initial version --- .github/workflows/python-package.yml | 2 +- CHANGES.md | 5 ++ NEWS.md | 9 +++ README.md | 4 +- TODO.md | 2 +- pyproject.toml | 2 +- setup.py | 2 +- tests/test_woad.py | 29 ++++++++- woad/__init__.py | 91 +++++++++++++++++++++++++++- 9 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 NEWS.md diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index bd8aab5..1fa4359 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -66,7 +66,7 @@ jobs: python -m pip install build python -m build python -m pip install dist/woad-*.whl - python -c "import woad; assert woad.__version__ == '0.0.0'; print(woad.__version__)" + python -c "import woad; assert woad.__version__ == '0.0.1'; print(woad.__version__)" build-py27: diff --git a/CHANGES.md b/CHANGES.md index b9324d3..2477a70 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,11 @@ # woad.Python - Changes +## 0.0.1 - 15th August 2026 + +* SGR colour and reset codes (`RESET`, `FG_*`, `BG_*`, including bright variants); + + ## 0.0.0 - 15th August 2026 * initial project scaffolding; diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..fb5536a --- /dev/null +++ b/NEWS.md @@ -0,0 +1,9 @@ +# woad.Python - News + +| Date | News Item | +| ---------------- | ------------------------------------------------------------------------------------------ | +| 15th August 2026 | [**woad.Python** 0.0.1](https://github.com/synesissoftware/woad.Python/releases/tag/0.0.1) | +| 15th August 2026 | [**woad.Python** 0.0.0](https://github.com/synesissoftware/woad.Python/releases/tag/0.0.0) | + + + diff --git a/README.md b/README.md index 6191a0f..8de3488 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,14 @@ Use via **import**: ```Python import woad + +print(woad.FG_GREEN + "ok" + woad.RESET) ``` ## Components -**woad.Python** currently ships the **`woad`** package and version metadata (`woad.__version__`). Colour codes, TTY/stream gating, and Windows virtual-terminal opt-in are not implemented in this 0.0.0 skeleton. +**woad.Python** ships SGR string constants (`RESET`, `FG_*`, `BG_*`, including bright variants). TTY/stream gating and Windows virtual-terminal opt-in are not implemented yet. ## Project Information diff --git a/TODO.md b/TODO.md index 9b7e03e..3a58029 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ ## Functional improvements -* [ ] SGR colour and reset codes; +* [x] ~~~SGR colour and reset codes~~~ ✅; * [ ] TTY-conditional colour codes (process and per-stream); * [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode`); diff --git a/pyproject.toml b/pyproject.toml index ed2f41d..c819640 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ license = { text = "BSD-3-Clause" } name = "woad" readme = "README.md" requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*" -version = "0.0.0" +version = "0.0.1" [project.urls] "Bug Tracker" = "https://github.com/synesissoftware/woad.Python/issues" diff --git a/setup.py b/setup.py index b52737c..ce7eba8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ name='woad', python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*', - version='0.0.0', + version='0.0.1', author='Matt Wilson', author_email='matthew@synesis.com.au', diff --git a/tests/test_woad.py b/tests/test_woad.py index 3d13b4b..9ed9b3a 100644 --- a/tests/test_woad.py +++ b/tests/test_woad.py @@ -7,4 +7,31 @@ class Test_woad(unittest.TestCase): def test_version(self): - self.assertEqual('0.0.0', woad.__version__) + self.assertEqual('0.0.1', woad.__version__) + + def test_RESET(self): + + self.assertEqual('\033[0m', woad.RESET) + + def test_FG_RED(self): + + self.assertEqual('\033[31m', woad.FG_RED) + + def test_BG_BLUE(self): + + self.assertEqual('\033[44m', woad.BG_BLUE) + + def test_all_codes_are_csi_sgr(self): + + for name in woad.__all__: + + code = getattr(woad, name) + + self.assertTrue( + code.startswith('\033['), + name, + ) + self.assertTrue( + code.endswith('m'), + name, + ) diff --git a/woad/__init__.py b/woad/__init__.py index 37096dd..4210930 100644 --- a/woad/__init__.py +++ b/woad/__init__.py @@ -12,5 +12,94 @@ __license__ = 'BSD-3-Clause' __maintainer__ = 'Matt Wilson' __status__ = 'Alpha' -__version__ = '0.0.0' +__version__ = '0.0.1' + +# Reset + +RESET = '\033[0m' + + +# Foreground (standard) + +FG_BLACK = '\033[30m' +FG_RED = '\033[31m' +FG_GREEN = '\033[32m' +FG_YELLOW = '\033[33m' +FG_BLUE = '\033[34m' +FG_MAGENTA = '\033[35m' +FG_CYAN = '\033[36m' +FG_WHITE = '\033[37m' + + +# Foreground (bright) + +FG_BRIGHT_BLACK = '\033[90m' +FG_BRIGHT_RED = '\033[91m' +FG_BRIGHT_GREEN = '\033[92m' +FG_BRIGHT_YELLOW = '\033[93m' +FG_BRIGHT_BLUE = '\033[94m' +FG_BRIGHT_MAGENTA = '\033[95m' +FG_BRIGHT_CYAN = '\033[96m' +FG_BRIGHT_WHITE = '\033[97m' + + +# Background (standard) + +BG_BLACK = '\033[40m' +BG_RED = '\033[41m' +BG_GREEN = '\033[42m' +BG_YELLOW = '\033[43m' +BG_BLUE = '\033[44m' +BG_MAGENTA = '\033[45m' +BG_CYAN = '\033[46m' +BG_WHITE = '\033[47m' + + +# Background (bright) + +BG_BRIGHT_BLACK = '\033[100m' +BG_BRIGHT_RED = '\033[101m' +BG_BRIGHT_GREEN = '\033[102m' +BG_BRIGHT_YELLOW = '\033[103m' +BG_BRIGHT_BLUE = '\033[104m' +BG_BRIGHT_MAGENTA = '\033[105m' +BG_BRIGHT_CYAN = '\033[106m' +BG_BRIGHT_WHITE = '\033[107m' + + +__all__ = [ + 'BG_BLACK', + 'BG_BLUE', + 'BG_BRIGHT_BLACK', + 'BG_BRIGHT_BLUE', + 'BG_BRIGHT_CYAN', + 'BG_BRIGHT_GREEN', + 'BG_BRIGHT_MAGENTA', + 'BG_BRIGHT_RED', + 'BG_BRIGHT_WHITE', + 'BG_BRIGHT_YELLOW', + 'BG_CYAN', + 'BG_GREEN', + 'BG_MAGENTA', + 'BG_RED', + 'BG_WHITE', + 'BG_YELLOW', + 'FG_BLACK', + 'FG_BLUE', + 'FG_BRIGHT_BLACK', + 'FG_BRIGHT_BLUE', + 'FG_BRIGHT_CYAN', + 'FG_BRIGHT_GREEN', + 'FG_BRIGHT_MAGENTA', + 'FG_BRIGHT_RED', + 'FG_BRIGHT_WHITE', + 'FG_BRIGHT_YELLOW', + 'FG_CYAN', + 'FG_GREEN', + 'FG_MAGENTA', + 'FG_RED', + 'FG_WHITE', + 'FG_YELLOW', + 'RESET', +] From f79457d34fe8170f903192df387a5fbc761823e6 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Sat, 15 Aug 2026 18:46:36 +1000 Subject: [PATCH 2/2] related projects --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8de3488..e34d50c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ None (currently). ### Related projects +* [**woad**](https://github.com/synesissoftware/woad/) * [**woad.Ruby**](https://github.com/synesissoftware/woad.Ruby/) * [**woad.Rust**](https://github.com/synesissoftware/woad.Rust/)