Skip to main content

A utility library for Python development

Project description

winiutils

pyrig uv Container pre-commit 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.53.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.53-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: winiutils-2.3.53.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.53.tar.gz
Algorithm Hash digest
SHA256 832c415fca9bfc11ddab9432c3ab750abd2faa74490189b98ed2f428d79314ac
MD5 5170193535da2d5e808fbc496051b9da
BLAKE2b-256 c510ad069be5bc968883bf6061239ce7d1e28c9acd51ea574f58f6ab25ce2e87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: winiutils-2.3.53-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.53-py3-none-any.whl
Algorithm Hash digest
SHA256 d8f575a1d6a62b934cd1c8e87ae226d287f19050e3542fe206a49b254bdf849f
MD5 ba453d6c8a7df596fe4bd8c5d2b3681d
BLAKE2b-256 4fbf46528d78b5d10255fe68a4e4678f70e62e813cc4672ae5c8841565bef4e8

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