Skip to main content

A utility library for Python development

Project description

winiutils

pyrig uv Container prek MkDocs

ruff ty security: bandit pytest codecov rumdl

PyPI Python License

CI CD

Documentation


A utility library for Python development


Table of Contents


Features

  • DataFrame Cleaning Pipeline Extensible Polars DataFrame cleaning with an 8-step pipeline
  • Concurrent Processing Unified multiprocessing and multithreading with automatic resource optimization
  • OOP Utilities Metaclasses and mixins for automatic method logging and instrumentation
  • Security Tools — OS keyring integration and AES-GCM encryption utilities
  • Type Safety — Full type hints with strict mypy compliance
  • Production Ready — Comprehensive test coverage and logging integration

Installation

Using uv (recommended)

uv add winiutils

Using pip

pip install winiutils

From source

git clone https://github.com/Winipedia/winiutils.git
cd winiutils
uv sync

Quick Start

DataFrame Cleaning

from winiutils.src.data.dataframe.cleaning import CleaningDF
import polars as pl

class UserDataCleaner(CleaningDF):
    """Clean and standardize user data."""

    USER_ID = "user_id"
    EMAIL = "email"
    SCORE = "score"

    @classmethod
    def get_rename_map(cls):
        return {cls.USER_ID: "UserId", cls.EMAIL: "Email", cls.SCORE: "Score"}

    @classmethod
    def get_col_dtype_map(cls):
        return {
            cls.USER_ID: pl.Int64, cls.EMAIL: pl.Utf8, cls.SCORE: pl.Float64
        }

    # ... implement other abstract methods

# Usage
cleaned = UserDataCleaner(raw_dataframe)
result = cleaned.df

Concurrent Processing

from winiutils.src.iterating.concurrent.multiprocessing import multiprocess_loop
from winiutils.src.iterating.concurrent.multithreading import multithread_loop

# CPU-bound tasks (multiprocessing)
def process_chunk(data, config):
    return heavy_computation(data, config)

results = multiprocess_loop(
    process_function=process_chunk,
    process_args=[(chunk,) for chunk in data_chunks],
    process_args_static=(config,),
    process_args_len=len(data_chunks),
)

# I/O-bound tasks (multithreading)
def fetch_url(url, headers):
    return requests.get(url, headers=headers)

results = multithread_loop(
    process_function=fetch_url,
    process_args=[(url,) for url in urls],
    process_args_static=(headers,),
    process_args_len=len(urls),
)

Automatic Method Logging

from winiutils.src.oop.mixins.mixin import ABCLoggingMixin

class MyService(ABCLoggingMixin):
    def process_data(self, data: list) -> dict:
        # Automatically logged with timing
        return {"processed": len(data)}

# Logs: "MyService - Calling process_data with (...) and {...}"
# Logs: "MyService - process_data finished with 0.5 seconds -> returning {...}"

Encryption with Keyring

from winiutils.src.security.keyring import get_or_create_aes_gcm
from winiutils.src.security.cryptography import (
    encrypt_with_aes_gcm, 
    decrypt_with_aes_gcm
)

# Get or create encryption key (stored in OS keyring)
aes_gcm, key = get_or_create_aes_gcm("my_app", "user@example.com")

# Encrypt and decrypt
encrypted = encrypt_with_aes_gcm(aes_gcm, b"Secret message")
decrypted = decrypt_with_aes_gcm(aes_gcm, encrypted)

Documentation

Full documentation is available in the docs folder:


Modules

Module Description
winiutils.src.data DataFrame cleaning pipeline and data structure utilities
winiutils.src.iterating Concurrent processing with multiprocessing and multithreading
winiutils.src.oop Metaclasses and mixins for automatic method logging
winiutils.src.security AES-GCM encryption and OS keyring integration

Development

Setup

git clone https://github.com/Winipedia/winiutils.git
cd winiutils
uv sync --all-groups

Running Tests

uv run pytest

Code Quality

# Linting
uv run ruff check .

# Type checking
uv run mypy .

# Security scanning
uv run bandit -r winiutils/

Pre-commit Hooks

uv run pre-commit install
uv run pre-commit run --all-files

Project Structure

winiutils/
├── src/                          # Main source code
│   ├── data/                     # Data processing
│   │   ├── dataframe/            # Polars DataFrame cleaning
│   │   └── structures/           # Dicts, text utilities
│   ├── iterating/                # Iteration utilities
│   │   └── concurrent/           # Multiprocessing & multithreading
│   ├── oop/                      # OOP patterns
│   │   └── mixins/               # Logging metaclass & mixin
│   └── security/                 # Security utilities
│       ├── cryptography.py       # AES-GCM encryption
│       └── keyring.py            # OS keyring integration
├── dev/                          # Development tools
│   ├── cli/                      # CLI subcommands
│   └── tests/fixtures/           # Test fixtures
├── docs/                         # Documentation
└── tests/                        # Test suite

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Please ensure:

  1. All tests pass (uv run pytest)
  2. Code passes linting (uv run ruff check .)
  3. Types are correct (uv run mypy .)
  4. New features include tests
  5. Documentation is updated for API changes

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

winiutils-2.3.58.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

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

winiutils-2.3.58-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file winiutils-2.3.58.tar.gz.

File metadata

  • Download URL: winiutils-2.3.58.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for winiutils-2.3.58.tar.gz
Algorithm Hash digest
SHA256 4337d21249f04f534289a36c8ebcab486b2ff0c30df04f2e0e7fbb97a4874a1c
MD5 68b711dbed03af6d0b8eb4a6473b220f
BLAKE2b-256 fc5a9d9068e7f658b1c682f88c1e3ec80f3e1c326f0629672f9a8805d7d8ca17

See more details on using hashes here.

File details

Details for the file winiutils-2.3.58-py3-none-any.whl.

File metadata

  • Download URL: winiutils-2.3.58-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for winiutils-2.3.58-py3-none-any.whl
Algorithm Hash digest
SHA256 b336a9338cdca42fe926e730f1dd68e900d09b158d9224f727f51472fe0fcd32
MD5 ae82211d8a39532eef3f9ede34f52d60
BLAKE2b-256 79d15c07d3a86408461952a0b031afb88261000110efdc92e98bc07c6425b70b

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