Skip to main content

This project contains common and generic functions, decorators, interfaces and classes...

Project description

core-mixins

This project contains common functions, decorators, and mixin classes as the base for other projects or libraries…


Python Versions License Pipeline Status Docs Status Security

Installation

Install from PyPI using pip:

pip install core-mixins
uv pip install core-mixins  # Or using UV...

Features

This library provides the following modules and utilities:

Compatibility
  • Self - Type hint for self-referential classes

  • StrEnum - String enumeration compatibility across Python versions

Decorators (core_mixins.decorators)
  • cache / cache_memory_based - In-memory LRU memoization with optional maxsize and ttl

  • cache_file_based - Write-through two-level cache (L1 memory + L2 disk), survives process restarts

  • count_calls - Track function call counts

  • repeat - Execute functions multiple times

  • retry - Automatic retry with configurable backoff

  • singleton - Enforce single instance pattern

  • SyncWrapper - Convert async functions to synchronous

  • with_timeout - Subprocess-based timeout, cross-platform, sub-second precision

  • with_timeout_signal - Signal-based timeout (Unix/Linux only), minimal overhead

  • timer - Measure function execution time

File Utilities (core_mixins.files)
  • records_from_csv / records_to_csv - CSV file handling

  • records_from_buffer / records_to_buffer - In-memory CSV operations

Interfaces (core_mixins.interfaces)
  • IFactory - Factory pattern interface

  • ITask - Task interface with status tracking

  • TaskStatus - Task state enumeration

  • TaskException - Task-specific exceptions

Managers (core_mixins.managers)
  • TasksManager - Manage and execute multiple tasks

  • TaskResult - Task execution result container

Logging (core_mixins.logger)
  • get_logger - Standardized logger configuration

Utilities (core_mixins.utils)
  • random_string - Generate random strings

  • get_batches - Batch list processing

  • remove_attributes / rename_attributes / add_attributes - Dictionary manipulation

  • convert_data_type - Type conversion utilities

  • to_snake_case - Convert strings to snake_case

  • flatten_json - Flatten nested JSON structures

  • to_one_line - Convert multiline strings to single line

  • bytes_to_str - Convert bytes to string

Exceptions (core_mixins.exceptions)
  • get_exception_data - Extract structured exception information

CLI Utilities (core_mixins.cli)
  • ProgressTracker - TTY-aware progress bar; animates on real terminals, falls back to logger.info on Lambda/ECS/CI. Built as a zero-dependency alternative to tqdm, keeping core-mixins dependency-free so it does not pull transitive packages into production services where supply-chain surface area and package size matter.

Quick Start

Installation

Install the package:

pip install core-mixins
uv pip install core-mixins  # Or using UV...
pip install -e ".[dev]"    # For development...

Setting Up Environment

  1. Install required libraries:

pip install --upgrade pip
pip install virtualenv
  1. Create Python virtual environment:

virtualenv --python=python3.12 .venv
  1. Activate the virtual environment:

source .venv/bin/activate

Install packages

pip install .
pip install -e ".[dev]"

Check tests and coverage

python manager.py run-tests                             # unit tests (default)
python manager.py run-tests -t integration              # integration tests
python manager.py run-tests -t functional -p "*.py"     # functional tests
python manager.py run-coverage                          # all tests with coverage

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: python manager.py run-tests

  5. Run linting: pylint core_mixins

  6. Run security checks: bandit -r core_mixins

  7. Submit a pull request

License

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

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

Project details


Download files

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

Source Distribution

core_mixins-3.2.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

core_mixins-3.2.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file core_mixins-3.2.0.tar.gz.

File metadata

  • Download URL: core_mixins-3.2.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for core_mixins-3.2.0.tar.gz
Algorithm Hash digest
SHA256 eed1e1de4b9e6feb762ffc24003f863d9a35b8e3017f5ea74a64e139bc791ea8
MD5 4a5c04c5573bec2ea9efa13b63697185
BLAKE2b-256 47bcbe047ab9e9d5663517b79ed05350f23c973bb4d7085a50c9dd2dffdb2344

See more details on using hashes here.

File details

Details for the file core_mixins-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: core_mixins-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for core_mixins-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50109d3a149341b1a9298461b12ceb6f5083694f79292fc659e1db748d2ab3e9
MD5 8a335a6ae739b2948eb452870407128f
BLAKE2b-256 68c295369f7c14b7b8756a56c2ba9c8f3c5d7919a8ab84d45b8c7dfa34fec915

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