Skip to main content

Reusable classes, functions and abstractions to avoid reinventing the wheel.

Project description

Zut

Reusable classes, functions and abstractions to avoid reinventing the wheel.

This library provides many general-purpose classes and functions, that I found myself needing in many contexts over the years, as complements to the Python standard library.

It also defines common database abstractions to access various backends (Postgres, MariaDB, etc) as well as file abstractions on various backends (Samba/NFS, S3, etc), in a standardized way, for usual operations.

It also has a specific focus on easing transfer of tabular data to and from different sources (Excel, databases, etc) using CSV as a common communication (dump and load functions).

Installation

Zut package is published on PyPI. It requires Python version >= 3.7.

Install without any dependency (no dependency is mandatory):

pip install zut

It is also possible to install with an extra specifier to add optional dependencies, for example:

pip install zut[pg]

Avalable extra specifiers

Please note that no dependency is mandatory to use Zut, if you don't need any of the features below.

File backends

For zut.files package:

  • pip install zut[smb]: access to Samba/Windows shares (installs smbprotocol).
  • pip install zut[s3]: access to S3 buckets (installs boto3).
  • pip install zut[zip]: access to Zip archives (installs zipp, necessary only for Python < 3.10 to mitigate a bug in the standard library).

Database backends

For zut.db package:

  • pip install zut[pg] (synonym: zut[postgresql]): access PostgreSQL databases (installs psycopg and sqlparse).
  • pip install zut[mysql] (synonyms: zut[mariadb]): access MySQL and MariaDB databases (installs mysqlclient and sqlparse).
  • pip install zut[sqlserver] (synonym: zut[mssql]): access Microsoft SQL Server databases (installs pyodbc, sqlparams and sqlparse).
  • pip install zut[sqlite]: access SQLite databases (installs sqlparse).

The tz extra specifier (see below) is automatically included with all database extra specifiers.

Miscellaneous features

  • pip install zut[tz] : parse timezones from string, get local timezone name or convert between naive and aware datetimes in various timezones (installs tzdata and tzlocal on Windows). This extra specifier does not install anything on Linux (for Python >= 3.9) because this feature is natively available.
  • pip install zut[tabulate] : display tabular data elegantly (installs tabulate). If this dependency is not included, the library provides a polyfill for the tabulate function to handle simple cases.
  • pip install zut[excel] : manage Excel files with zut.excel module (installs openpyxl and defusedxml).
  • pip install zut[django] : Django utilities available in zut.django package (installs django).
  • pip install zut[perf] : track memory performance using zut.perf package (installs psutil).

Features

See full documentation (including API reference).

Module Summary
zut Top-level API: most commonly reused utilities (Color, encoding, errors, etc).
zut.api A JSON-oriented API client using only Python standard library.
zut.callback HTTP callback server (for redirects of authorization flows).
zut.choices Allow usage of entity classes defined in libraries that may or may not have Django as a dependency depending on the library usage.
zut.commands Define and run command-line applications.
zut.config Configure and access configuration of the system: logging, dotenv, locale.
zut.convert Flexible convert functions.
zut.csv Write and read CSV tables.
zut.db A standardized abstraction to access different database backends.
zut.db.mariadb Implementation of zut.db for the MariaDB database backend.
zut.db.mysql Implementation of zut.db for the MySQL database backend.
zut.db.pg Implementation of zut.db for the PostgreSQL database backend.
zut.db.sqlite Implementation of zut.db for the SQLite database backend.
zut.db.sqlserver Implementation of zut.db for the Sql Server database backend.
zut.django Common utilities for Django applications.
zut.excel Write and read Excel tables.
zut.files A standardized abstraction to access different kinds of "files": entries of ZIP archives, samba shares, S3 objects, access via sudo.
zut.files.s3 Implementation of zut.files for S3-compatible buckets.
zut.files.smb Implementation of zut.files for Windows/Samba shares.
zut.files.sudo Implementation of zut.files to access files via sudo.
zut.files.zip Implementation of zut.files for entries of ZIP archives.
zut.gpg GPG and pass utilities.
zut.graph Graph utilities.
zut.json Write and read using JSON format.
zut.net Resolve network information (DNS resolution with a timeout, port status, system proxy, etc).
zut.perf Measurement of elapsed time and memory consumption.
zut.polyfills Implement features used within Zut, that are currently part of the Python standard library, for older versions of Python.
zut.process Common wrappers over subprocess.run.
zut.slugs Generate slugs and provide flexible string filters.
zut.tabulate Emulate a basic tabulate function in case the original tabulate package (developped by Sergey Astanin) is not available as a dependency.
zut.term Write temporary text on the console.
zut.tz Parse and convert timezones.
zut.unittest Utilities for unit tests.
zut.urls Build URLs.

Contribute

Pull requests are welcome.

See contributing guidelines.

Credits

This project is licensed under the terms of the MIT license.

Logo by Eric Watson - Dreamstime.com ("Royalty-free vector").

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zut-3.2.1-py3-none-any.whl (159.3 kB view details)

Uploaded Python 3

File details

Details for the file zut-3.2.1-py3-none-any.whl.

File metadata

  • Download URL: zut-3.2.1-py3-none-any.whl
  • Upload date:
  • Size: 159.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for zut-3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03b7073fe10fc0e45840e1ac8e6487bb32e56bb8b3049d9432d3bf0f5f2a4832
MD5 a12263c261a4d22623df89e41c991fba
BLAKE2b-256 6b3873bb727effb8ffcdf19cc2bdc1f2b2ee761e1cc7a5efcf1f52ae4f3b0937

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page