A modular Python library with utilities for flattening, file parsing, error handling, and more.
Project description
PythonByzaticCommons
PythonByzaticCommons is a modular utility library for Python that provides a collection of reusable components for file reading, exception handling, logging, in-memory storage, singleton management, and more. Designed for extensibility and clean architecture, it helps accelerate development by offering ready-to-use patterns and interfaces.
Artifact available on pypi:
https://pypi.org/project/python-byzatic-commons/0.1.0/
pip install python-byzatic-commons
Modules Overview
exceptions
A set of structured exception classes to formalize error handling in complex systems.
BaseErrorException: Root base class for domain-specific exceptions.OperationIncompleteException: Indicates partial success or failure in operations.ExitHandlerException: Used to trigger early exit logic in controlled flows.CriticalErrorException: Raised for non-recoverable fatal errors.NotImplementedException: Placeholder for yet-to-be-implemented logic.
filereaders
Unified interfaces and concrete implementations for parsing configuration files.
-
Interfaces:
BaseReaderInterface: Defines contract for readers returning a dict from a file.
-
Readers:
JsonFileReader: Loads.jsonfiles into Python dictionaries.YamlFileReader: Loads.yaml/.ymlfiles usingPyYAML.ConfigParserFileReader: Loads.ini-style config files usingconfigparser.
All readers validate input paths and support standard Python error handling.
in_memory_storages
In-memory key-value storage layer with interchangeable implementations and management.
-
Interfaces:
KeyValueDictStorageInterface,KeyValueListStorageInterface, etc.
-
Storages:
KeyValueDictStorage: Usesdictinternally.KeyValueListStorage: Useslistfor indexed access.KeyValueObjectStorage: Stores arbitrary Python objects.KeyValueStringStorage,KeyValueModuleTypeStorage, etc.
-
Manager:
StoragesManager: Central registry and access point for storage instances.
Test coverage is included in the test/ directory.
logging_manager
Encapsulates logging configuration and output.
LoggingManagerInterface: Describes basic logging interface (info,warn,error, etc.)LoggingManager: Concrete implementation wrapping Python’s built-inloggingmodule with a consistent configuration.
Supports colored output, custom formatters, and stream redirection.
singleton
Provides a class-based singleton pattern.
Singleton: A metaclass-based implementation that ensures a class has only one instance across the application.
Useful for shared services like loggers, configuration managers, etc.
Example Usage
from python_byzatic_commons.filereaders import JsonFileReader
reader = JsonFileReader()
config = reader.read("config.json")
import os
import logging
from python_byzatic_commons.logging_manager import LoggingManager
system_script_dir = os.path.abspath(os.path.dirname(__file__))
logger_config_file_path_json = os.path.join(
system_script_dir,
'configuration',
'logger_configuration.json'
)
logging_manager: LoggingManager = LoggingManager()
logging_manager.init_logging(
logger_config_file_path_json,
"JSON"
)
applogger = logging.getLogger("Application-logger")
applogger.debug(f"Creating context")
License
This project is licensed under the terms of the Apache 2.0 license.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_byzatic_commons-0.1.6.tar.gz.
File metadata
- Download URL: python_byzatic_commons-0.1.6.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a2a2e9557ba91f22410ee1b52daaf7fee7521a5a98d141ac9f214c9c97b749e
|
|
| MD5 |
205bb84ea24b9e079653f881885a328f
|
|
| BLAKE2b-256 |
5c01fe1fffcd7587b52b47fe8bae72b00ccee218e0c12099efeac463c502a88c
|
File details
Details for the file python_byzatic_commons-0.1.6-py3-none-any.whl.
File metadata
- Download URL: python_byzatic_commons-0.1.6-py3-none-any.whl
- Upload date:
- Size: 59.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81c84a46fc1cd68aafeebc56686fcc70d1d8b86e07f30ea62a1994771138885d
|
|
| MD5 |
95cddff73cfa5de426bc0c54b84afe4b
|
|
| BLAKE2b-256 |
d50aa177619003f20f804ea279b0e55ea7f230e0cf7ea056842795b54d24959f
|