Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = true

# Language indent/EOL/charset overlap with .vscode/settings.json.
# Rulers, renderWhitespace, detectIndentation, mergeEditor, and
# language-server settings cannot be expressed here — they stay in
# settings.json.

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

# [json]
[*.json]
indent_size = 2
indent_style = space

# [markdown]
[*.md]
indent_size = 2
indent_style = space

# [python]
[*.py]
indent_size = 4
indent_style = space

# [shellscript]
[*.{bash,sh,zsh}]
indent_size = 2
indent_style = space

# [toml]
[*.toml]
indent_size = 2
indent_style = tab

# [yaml]
[*.{yaml,yml}]
indent_size = 2
indent_style = space
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.c linguist-language=C
*.cpp linguist-language=C++
*.h linguist-language=C
*.hpp linguist-language=C++
*.html linguist-detectable=false
*.py linguist-language=Python
*.sh linguist-detectable=false
*.vimrc linguist-detectable=false
makefile linguist-detectable=false
44 changes: 37 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# the sdist/wheel on a range of Python versions.
#
# Created: 15th August 2026
# Updated: 15th August 2026
# Updated: 17th November 2026
#

name: Python package

on:
push:
branches:
- boilerplate
- master
- dev
- boilerplate
- idiomatic
- master
- rc1
- rc2
- rc3
Expand All @@ -27,20 +27,50 @@ defaults:
shell: bash

jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest

steps:
- name: Checking out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff

- name: Lint with ruff
run: |
ruff check .

build:

runs-on: ubuntu-latest
# 3.8 and 3.9 have no setup-python build for Ubuntu 26.04
# (ubuntu-latest). Those cells stay on ubuntu-24.04 so the 3.8 floor
# remains exercised.
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
include:
- os: ubuntu-24.04
python-version: "3.8"
- os: ubuntu-24.04
python-version: "3.9"

steps:
- name: Checking out code
Expand All @@ -66,7 +96,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.1'; print(woad.__version__)"
python -c "import woad; assert woad.__version__ == '0.1.0-alpha1'; print(woad.__version__)"

build-py27:

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@

# directories (by name)

/.bin/
/.pytest_cache/
/.ruff_cache/
/.venv/

build/
dist/
dist-old/
scratch/

*.egg-info/


# directories (by pattern)

**/__pycache__/


# files (by name)

.DS_Store

notes.txt


# files (by pattern)

Expand Down
1 change: 1 addition & 0 deletions .sis/project_name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
woad.Python
2 changes: 2 additions & 0 deletions .sis/script_info_lines.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
woad.Python provides minimal ANSI terminal colour codes for Python
Copyright (c) 2026, Matthew Wilson and Synesis Information Systems
57 changes: 57 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
" Synesis Python project .vimrc — aligned with .vscode/settings.json (Python)

set nocompatible
filetype indent plugin on
syntax enable
set autoindent
set backspace=indent,eol,start
set hlsearch
set incsearch
set number

" files.insertFinalNewline
set eol
set fixeol

" editor.renderWhitespace: all
set list
set listchars=tab:->,trail:-,extends:>,precedes:<,nbsp:+

" editor.detectIndentation: false — global defaults match [python] (editor.tabSize: 4, insertSpaces: true)
set colorcolumn=76
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4

" colorcolumn draws a full-column tint in Vim (not a VS Code-style 1px line).
" Keep it subtle via the ColorColumn highlight group; reapply after colorscheme changes.
if has('termguicolors')
" set termguicolors
endif

function! s:ConfigureColorColumn() abort
highlight ColorColumn ctermbg=236 guibg=#2a2a2a cterm=NONE gui=NONE
endfunction

call s:ConfigureColorColumn()
autocmd ColorScheme * call s:ConfigureColorColumn()

" files.trimTrailingWhitespace
autocmd BufWritePre * %s/\s\+$//e

augroup sis_python
autocmd!

" [json] / [markdown] / [yaml]
autocmd FileType json,markdown,yaml setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2

" [python] — match .vscode [python] tabSize 4 / insertSpaces true / rulers 50,60,76,120
autocmd FileType python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 colorcolumn=50,60,76,120

" [shellscript]
autocmd FileType sh,bash,zsh setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 colorcolumn=60,76

" [toml]
autocmd FileType toml setlocal noexpandtab tabstop=2 shiftwidth=2 softtabstop=2
augroup END
43 changes: 43 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"[json]": {
"editor.tabSize": 2,
},
"[markdown]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
},
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
"editor.insertSpaces": true,
"editor.rulers": [ 50, 60, 76, 120 ],
"editor.tabSize": 4,
},
"[shellscript]": {
"editor.insertSpaces": true,
"editor.rulers": [ 60, 76 ],
"editor.tabSize": 2,
},
"[toml]": {
"editor.insertSpaces": false,
"editor.tabSize": 2,
},
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
},
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.renderWhitespace": "all",
"editor.rulers": [ 76 ],
"editor.tabSize": 2,
"files.exclude": {
"**/*.egg-info": true,
"**/*.swp": true,
"**/__pycache__": true,
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"git.mergeEditor": false,
"python.analysis.typeCheckingMode": "standard",
"python.languageServer": "Pylance",
}
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# woad.Python - Changes <!-- omit in toc -->


## 0.1.0-alpha1 - 17th November 2026

* Added `BLINKING` and `BOLD`;
* Portable colour policy (`colour_policy`, `refresh`, `supports_colour`, `seq_for`), including `TERM=dumb` and file attachment;
* Windows virtual-terminal gating and mintty recognition are not in this alpha;


## 0.0.2 - 14th September 2026

* packaging, documentation, and CI modernisation (canonical CI, **ruff**, helper scripts, **MANIFEST.in**);


## 0.0.1 - 15th August 2026

* SGR colour and reset codes (`RESET`, `FG_*`, `BG_*`, including bright variants);
Expand Down
10 changes: 6 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# woad.Python - News <!-- omit in toc -->

| 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) |
| Date | News Item | Details |
| ------------------- | ------------------------------------------------------------------------------------------ | ------- |
| 17th November 2026 | [**woad.Python** 0.1.0-alpha1](https://github.com/synesissoftware/woad.Python/releases/tag/0.1.0-alpha1) | `BOLD`, `BLINKING`; portable colour policy; Windows VT not in this alpha |
| 14th September 2026 | [**woad.Python** 0.0.2](https://github.com/synesissoftware/woad.Python/releases/tag/0.0.2) | Packaging / CI modernisation |
| 15th August 2026 | [**woad.Python** 0.0.1](https://github.com/synesissoftware/woad.Python/releases/tag/0.0.1) | SGR colour and reset codes |
| 15th August 2026 | [**woad.Python** 0.0.0](https://github.com/synesissoftware/woad.Python/releases/tag/0.0.0) | Initial scaffolding; Python 2.7 and 3.8+ |


<!-- ########################### end of file ########################### -->
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Minimal ANSI terminal colour codes, for Python
## Table of Contents <!-- omit in toc -->

- [Introduction](#introduction)
- [Developer Experience](#developer-experience)
- [Installation](#installation)
- [Components](#components)
- [Project Information](#project-information)
Expand All @@ -34,6 +35,32 @@ Minimal ANSI terminal colour codes, for Python
**woad.Python** is the **Python** implementation. It supports **Python 2.7** and **Python 3.8+**.


## Developer Experience

**Python 2.7** or **Python 3.8+** is required. The library uses the standard library only. From a checkout:

```bash
python -m unittest discover -s tests
python examples/conditional.py
```

The smallest useful call prints a sequence only when the stream supports colour:

```Python
import sys

import woad

stream = sys.stdout
green = woad.seq_for(stream, woad.FG_GREEN)
reset = woad.seq_for(stream, woad.RESET)

print(green + "ok" + reset)
```

That is [examples/conditional.py](./examples/conditional.py). Fixed sequences (`BOLD`, `BLINKING`, `FG_*`, `BG_*`) always contain the SGR bytes. `colour_policy`, `supports_colour`, and `seq_for` apply the cached environment policy. `refresh` drops that cache. A `None` sequence yields `""`.


## Installation

Install via **pip**:
Expand All @@ -53,7 +80,7 @@ print(woad.FG_GREEN + "ok" + woad.RESET)

## Components

**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.
**woad.Python** ships fixed SGR sequences (`BLINKING`, `BOLD`, `RESET`, `FG_*`, `BG_*`, including bright variants) and the portable colour policy: `colour_policy`, `refresh`, `supports_colour`, and `seq_for`. On Unix a terminal supports colour when the policy is automatic and `TERM` is not `dumb`. Windows virtual-terminal mode and mintty PTY recognition are not implemented.


## Project Information
Expand Down
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

## Functional improvements

* [x] ~~~SGR colour and reset codes~~~ ✅;
* [ ] TTY-conditional colour codes (process and per-stream);
* [ ] Windows virtual-terminal gating (OS build + `GetConsoleMode`);
* [x] ~~~SGR colour and reset codes~~~ - ✅;
* [x] ~~~portable colour policy (Unix attachment, `TERM=dumb`, conditional emission)~~~ - ✅;
* [ ] Windows virtual-terminal gating (`SetConsoleMode`, `WOAD_SET_CONSOLE_MODE`, mintty PTY names);


## Performance improvements
Expand Down
Loading
Loading