Zut
General-purpose utility Python library to minimize boilerplate code by reusing common code and patterns.
Install
Zut is published on PyPI.
Install with pip:
pip install zut
Zut is designed to work with the Python standard library (version >= 3.7) as its sole mandatory dependency.
Optional dependencies may be installed using an extra specifier:
pip install zut[excel]: write and read Excel files with modulezut.excel(installsopenpyxl defusedxml).pip install zut[tab]: display tabular data elegantly (installstabulate). If this dependency is not included, the library provides a polyfill for thetabulatefunction to handle simple cases.pip install zut[time]: parse timezones from string, get local timezone name or convert between naive and aware datetimes in various timezones (installstzdataandtzlocalon Windows; does not install anything on Linux if Python >= 3.9 because this feature is natively available).pip install zut[perf]: track elapsed time and memory consumption with modulezut.perf(installspsutil).pip install zut[sql]: advanced SQL parsing in modulezut.sql(installssqlparse).
Database adapters:
pip install zut[maria]: access MariaDB databases (installsmysqlclientandsqlparse).pip install zut[mysql]: access MySQL databases (installsmysqlclientandsqlparse).pip install zut[pg]: access PostgreSQL databases (installspsycopgandsqlparse).pip install zut[sqlserver]: access Microsoft SQL Server databases (installspyodbc,sqlparamsandsqlparse).pip install zut[sqlite]: access SQLite databases (installssqlparse).
Use pip install zut[all] to install all extras.
Features
Module |
Summary |
|---|---|
A JSON-oriented API client depending only on the Python standard library. |
|
Build helpers: get information about Git repositories, transpile makrdown files. |
|
HTTP callback server, typically used for redirects of authorization flows. |
|
Polyfills for Django’s |
|
Parse and convert lists and dicts. |
|
Define and run command-line interfaces. |
|
Extend ways to access |
|
Information about the execution context: script path and name, user scopes, SID, etc. |
|
Flexible conversion of types. |
|
Write and read CSV using flexible format options. |
|
Generic database access and tools. |
|
Base abstraction to access different database backends. |
|
Adapter for MariaDB databases. |
|
Adapter for MySQL databases. |
|
Adapter for PostgreSQL databases. |
|
Adapter for SQLite databases. |
|
Adapter for Microsoft SQL Server databases. |
|
Load |
|
Write and read Excel tables (requires |
|
Archivate files. |
|
Find geographical libraries. |
|
Encryption and decryption using GnuPG. |
|
Topological sort of dependency graphs |
|
Write and read JSON using extended encoder and decoder. |
|
Registration of locales and retrieval of information about locales. |
|
Configuration of logging and helpers for specific use cases. |
|
Resolve DNS with a timeout, check port status, determine proxy, etc. |
|
Parse and convert numbers. |
|
Manage passwords with GPG using |
|
Normalize and check paths, find paths to the root hierarchy, get default application directories. |
|
Track elapsed time and memory consumption (requires |
|
Install PyPi dependencies with |
|
Run processes and handle process errors (wrappers and extensions on stdlib’s |
|
Define and resolve secrets. |
|
Format and parse SQL queries. |
|
Provide a polyfill for the |
|
Console ANSI colors and live, interactive Console output. |
|
Manage UTF8 BOM, fix encoding issues, generate slugs, provide flexible filters. |
|
Parse and convert dates, times and time zones. |
|
Python typing helpers. |
|
Test runner wrapper and polyfills for |
|
Build and manipulate URLs. |
Contribute
Pull requests are welcome.
Legal
This project is licensed under the terms of the MIT license.
Logo by Eric Watson - Dreamstime.com (“Royalty-free vector”).
Documentation