Repository navigation
Releases: YoungLionOrganization/YoungLionTerminalPythonLibrary
Release list
v0.2
YoungLion Terminal Releases
v0.2.0 — YoungLion v0.1 Integration & Terminal Expansion
YoungLion Terminal v0.2 is the first release designed directly around the new YoungLion v0.1 core API. The goal is not only compatibility: v0.2 turns the package from a small ANSI helper collection into a more complete lightweight terminal toolkit while preserving the existing v0.1 public behavior wherever possible.
Compatibility with YoungLion v0.1
- The package now requires Python 3.10+, matching YoungLion v0.1.
- The dependency is explicitly constrained to
YoungLion>=0.1.0,<0.2.0so incompatible future core changes are not silently accepted. - Removed the obsolete
from YoungLion.DataModel import enable_ansidependency. - ANSI support is now owned by
YoungLion.terminal.ansi, including a best-effort Windows Virtual Terminal mode implementation. - Package metadata, CI and documentation now describe the actual YoungLion v0.1 compatibility line.
Logger / Debugger integration
YoungLion.terminal.Logger remains the same Terminal Logger concept and keeps its original methods:
debug()info()success()warning()error()critical()exception()set_level()- color/file/stream configuration
The class is now also a real subclass of both YoungLion.Debugger and YoungLion.Logger.
This makes the following valid:
from YoungLion import Debugger, File, Logger as CoreLogger
from YoungLion.terminal import Logger
logger = Logger()
assert isinstance(logger, Debugger)
assert isinstance(logger, CoreLogger)
file = File(debug=True, debugger=logger)Core method names do not replace the Terminal Logger implementation. They route back into it as aliases/wrappers:
log_debug()->debug()log_info()->info()log_warning()->warning()log_error()->error()log_critical()->critical()set_log_level()-> Terminalset_level()- Debugger
custom()routes through the Terminal Logger output pipeline instead of using a second independent printer.
The original Terminal set_level(str) behavior is preserved exactly. Because YoungLion.Debugger.set_level(int) uses the same method name for a different purpose, Debugger indentation is exposed through set_debugger_level(int) instead of changing Terminal Logger semantics.
Structured context is available through Logger.bind(...), and core log_* aliases can accept keyword fields while preserving Terminal output/file handling.
ANSI system improvements
New terminal capability tools:
enable_ansi()— self-contained Windows VT compatibility shim.supports_ansi()— detects TTY,NO_COLOR,FORCE_COLOR,TERM=dumband Windows VT support.strip_ansi()— removes ANSI CSI/OSC sequences.TerminalCapabilities/detect_capabilities()— terminal dimensions and broad rendering capability information.hidden_cursor()— safe cursor hide/show context manager.alternate_buffer()— safe alternate-screen context manager.hyperlink()— OSC-8 terminal hyperlinks.
Color.extended_256() and true-color helpers now validate channel ranges instead of emitting invalid ANSI sequences.
Progress system improvements
LoaderBar keeps its old arithmetic/comparison interface and gains:
ratioremainingcompletedset()advance()reset()complete()float(bar)percentage conversion
TerminalLoader gains:
- configurable output stream;
- thread-safe writes;
advance()alias;- subtraction support;
- context-manager support;
TerminalLoader.track(...)for automatic iterable progress;- ANSI stripping for redirected/non-TTY output.
Existing setStyle, upgrade, finish and setClearFinish behavior is retained.
Spinner improvements
Spinner is still usable exactly as before:
with Spinner("Working"):
do_work()v0.2 adds:
- explicit
start()/stop()lifecycle; succeed()andfail()completion states;- custom frame sequences;
- configurable output stream;
- thread-safe output;
- daemon worker thread;
- validation for invalid delays/empty frame sets.
New terminal widgets
v0.2 adds a small dependency-free widget layer:
Table
- Unicode bordered tables;
- automatic column sizing;
- headers and styled borders;
- optional cell truncation;
- sequence, mapping and
YoungLion.DDMrows.
Panel
- titled bordered content blocks;
- configurable padding and styles;
- string rendering or direct printing.
LiveLine
- thread-safe single-line updates;
- automatic overwrite padding;
- context-manager support;
- clear/finish lifecycle.
Targeted DDM support
DDM support was deliberately not added everywhere.
It is included only in APIs where structured models naturally become terminal presentation data:
print_dict(DDM(...))Table(..., rows=[DDM(...)])
The ANSI engine, progress engine, spinner and logger do not require DDM for normal operation. This keeps the terminal package conceptually clean and prevents unnecessary coupling.
Quality and packaging
- Added
py.typedmarker for inline type information. - Added pytest coverage for ANSI behavior, progress behavior, Logger inheritance/aliases, File debugger compatibility, widgets and DDM rendering.
- CI now targets Python 3.10, 3.11, 3.12, 3.13 and 3.14.
- CI installs the package with development extras and performs tests, Ruff checks, package build and Twine validation.
- README was rewritten to remove duplicated/obsolete v0.1 text and document the real v0.2 API.
- Every library class, function, property and class method now has detailed runtime docstrings.
- Every callable parameter is documented and type-annotated so IDLE/IDE signature help can explain arguments while users write code.
- Added
tests/test_docstrings.py, which fails CI when a source callable is missing a docstring, parameter description or type annotation.
Migration from v0.1
Most existing code can remain unchanged.
Old:
from YoungLion.terminal import Logger, LoaderBar, TerminalLoader, SpinnerStill valid in v0.2.
The primary environment change is Python/YoungLion compatibility:
python -m pip install --upgrade "YoungLion>=0.1,<0.2" "YoungLion-terminal>=0.2,<0.3"If application code previously imported enable_ansi from YoungLion.DataModel, use:
from YoungLion.terminal import enable_ansiinstead.
v0.1
Initial YoungLion Terminal release with ANSI constants, cursor/screen controls, loader/progress primitives, spinner, styled printing helpers and colored logging.
v0.1
YoungLion Terminal
Lightweight, well-documented ANSI terminal utilities for Python. This package
Table of contents
YoungLion Terminal
Advanced ANSI terminal utilities for Python — colors, text styles, cursor and
screen controls, progress loaders, spinners and a compact colored logger. This
library is focused on clear, consistent terminal output for CLI tools and
small scripts.
Repository: https://github.com/Cavanshirpro/YoungLionTerminalPythonLibrary
Table of contents
- Why use this library
- Installation
- Quick examples
- API summary
- Development & tests
- Publishing & GitHub
- Contribution guidelines
- Versioning & changelog
- License
- Contact
Why use this library
- Lightweight, dependency-free helpers that wrap standard ANSI sequences.
- Small, composable primitives (
LoaderBar,TerminalLoader,Spinner) that
are easy to embed in scripts. - A simple colored
Loggerand presentation helpers (print_boxed,
print_styled) for consistent CLI UX.
Installation
Development (editable install):
python -m pip install -e .Install from GitHub:
python -m pip install git+https://github.com/Cavanshirpro/YoungLionTerminalPythonLibrary.gitNotes
- Run commands from the repository root (where
pyproject.toml/setup.cfg
is located). - Use a terminal that supports ANSI escape codes (Windows Terminal, recent
PowerShell, macOS Terminal, Linux terminals).
Quick examples
These examples show common usage patterns.
- Progress bar
import time
from YoungLion.terminal import LoaderBar, TerminalLoader
bar = LoaderBar(length=10, full_part=0, bar_length=30)
loader = TerminalLoader(bar, "Download")
for _ in range(10):
loader += 1
time.sleep(0.12)
loader.finish()- Styled output
from YoungLion.terminal import print_styled, Color, TextStyle
print_styled("Status:", styles=(Color.BRIGHT_GREEN, TextStyle.BOLD), end=" ")
print_styled("OK", styles=(TextStyle.UNDERLINE,))- Spinner
import time
from YoungLion.terminal import Spinner, Color
with Spinner("Working…", style=Color.BRIGHT_CYAN):
time.sleep(2)
print("Done")- Logger
from YoungLion.terminal import Logger
log = Logger(name="myapp", level="INFO", log_to_file=False)
log.info("Service started")
log.success("Operation completed")API summary
Short reference to the publicly useful items (see module docstrings for full
details):
Color,BackgroundColor,TextStyle— SGR constants for styling text.CursorControl,ScreenControl,BufferControl— sequences to control the
terminal cursor and buffers.LoaderBar(length, full_part, bar_length=10)— progress value container.- Supports arithmetic and comparison dunder methods and
.percent.
- Supports arithmetic and comparison dunder methods and
TerminalLoader(bar, valueName)— in-place progress renderer.- Methods:
.update(),.setStyle(...),.finish(),.setClearFinish().
- Methods:
Spinner(text, delay=0.1, style=Color.BRIGHT_CYAN)— context-manager
spinner for blocking operations.print_styled,print_boxed,print_dict— convenience printing helpers.Logger— colored logger with.debug/.info/.success/.warning/.error/.critical/.exception().
Development & tests
Install test dependencies and run tests with pytest:
python -m pip install pytest
pytest -qThis repository includes a basic GitHub Actions workflow (.github/workflows/ci.yml)
that installs the package and runs tests on push/PR to main.
Publishing & GitHub
To push the repository to GitHub (replace <your-username> / repo if needed):
git init
git remote add origin https://github.com/Cavanshirpro/YoungLionTerminalPythonLibrary.git
git branch -M main
git add .
git commit -m "Initial commit"
git push -u origin mainUse the included uploadgithub.bat to commit and push from Windows:
uploadgithub.bat "Your commit message" [branch]To build distributions and upload to PyPI:
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*Contributing to YoungLion Terminal
Thank you for considering contributing — your help is appreciated.
Guidelines
- Fork the repository and create a new branch named
feature/<short-desc>or
fix/<short-desc>. - Keep PRs focused and include tests for new behaviour when possible.
- Follow the existing code style and docstring conventions.
Workflow
- Fork the repo and create a branch.
- Make changes and include tests/examples as appropriate.
- Commit with clear messages and push your branch.
- Open a Pull Request describing the change and motivation.
Tests & CI
- This repository uses GitHub Actions for CI. Tests run automatically on PRs.
- Run tests locally with
pytest.
Communication
- Open issues for feature requests or bugs before large changes — that helps
to align design decisions.
LICENSE
This project is licensed under the MIT License.
Authors
Main Developer
- Cavanşir Qurbanzadə - Lead Developer, Project Maintainer
If you want, I can now:
- Add more example scripts under
examples/and include sample outputs. - Add a minimal
.github/workflows/ci.yml(already added) or extend it to run
linting, packaging checks, or release automation. - Create
CONTRIBUTING.md&CHANGELOG.md(already added) or refine them.
Tell me which of these you'd like next and I'll continue.
or setup.cfg is located.
- On Windows, use Windows Terminal, PowerShell or a modern console that