# Advanced Python Utilities Module
This module provides a comprehensive set of utilities for advanced Python programming, including HTTP communication, string handling, logging enhancements, introspection, dynamic importing, property descriptors, data class extensions, and serialization. It is designed to facilitate complex application development by offering robust tools that extend Python's standard capabilities.
## Table of Contents
- [HTTP Communication Utilities](#http-communication-utilities)
- [String Handling Enhancements](#string-handling-enhancements)
- [Advanced Logging System](#advanced-logging-system)
- [Introspection and Reflection Utilities](#introspection-and-reflection-utilities)
- [Dynamic Importing Tools](#dynamic-importing-tools)
- [Advanced Property Descriptors](#advanced-property-descriptors)
- [Data Class Extensions and Configuration Handling](#data-class-extensions-and-configuration-handling)
- [Serialization and Deserialization Utilities](#serialization-and-deserialization-utilities)
## HTTP Communication Utilities
### Overview
This component provides a robust toolkit for handling HTTP communication. It includes advanced features for error handling, response parsing, cookie management, and URL processing. The utilities streamline building HTTP clients and services by abstracting common patterns and offering flexible, extensible components.
### Key Features
- **HTTPException Hierarchy**: A comprehensive set of exception classes for handling HTTP errors, based on status codes and error types.
- **Response Handling**: Utilities for parsing and processing HTTP responses, including automatic JSON decoding and error checking.
- **Cookie Management**: Tools for managing HTTP cookies, including parsing and formatting.
- **URL Processing**: Classes and functions for manipulating URLs, including query parameters and path components.
- **Serialization Decorators**: Decorators to facilitate serialization and deserialization of complex objects within the HTTP context.
- **Namespace Augmentation**: Enhancements to the HTTP namespace for convenient access to common utilities like `HTTP.URL`, `HTTP.Agent`, and `HTTP.Exception`.
## String Handling Enhancements
### Overview
Provides advanced string handling utilities focused on character encoding detection, conversion, and manipulation. It defines the `Str` class, acting as a wrapper around string or bytes objects, offering methods to handle various encoding scenarios and to facilitate text processing.
### Key Features
- **Encoding and Decoding**: Convert between bytes and string representations, handling different character encodings.
- **Charset Detection**: Automatically detects the character encoding of input data using custom logic and libraries.
- **Lazy Proxying**: Proxies common string methods to the underlying string representation, allowing `Str` instances to behave like regular strings.
- **Tokenization**: Methods to split strings into tokens based on regular expression patterns.
## Advanced Logging System
### Overview
Enhances the standard Python logging system by introducing custom log levels, additional logging utilities, and a more flexible logger configuration. It provides advanced logging capabilities suitable for complex applications that require detailed logging and traceability.
### Key Features
- **Custom Log Levels**: Defines additional log levels like `NOTICE`, `DEPRECATE`, and `VERBOSE` for finer-grained logging.
- **Logger Configuration**: Supports configuration from files (e.g., `logging.toml`), environment variables, or default settings.
- **Logger Extensions**: Provides a `Logger` class with enhanced methods for logging, including context-aware logging and deduplication of messages.
- **Integration with Modules**: Automatically injects the custom logger into modules, ensuring consistent logging behavior across the application.
## Introspection and Reflection Utilities
### Overview
Offers a collection of utility functions and classes for introspection, type checking, and reflection. It includes functions to analyze objects, their types, inheritance hierarchies, and modules.
### Key Features
- **Type Checking Functions**: Utilities like `is_callable`, `is_collection`, and `is_iterable` for checking object types.
- **Inheritance Utilities**: Functions to iterate over an object's MRO, get attributes from superclasses, and analyze class hierarchies.
- **Module and Object Inspection**: Tools to get the module of an object, its fully qualified name, source file, and other metadata.
- **Stack Inspection**: Functions to analyze the call stack, filter stack traces, and determine stack frame offsets.
## Dynamic Importing Tools
### Overview
Provides utilities for dynamic importing of modules and objects, with support for caching, handling optional dependencies, and enhanced error reporting.
### Key Features
- **Dynamic Importing**: Functions like `import_object` to import modules or objects by name at runtime.
- **Caching Imports**: `cached_import` function to memoize imports and improve performance.
- **Optional Dependencies**: `optional` function to handle optional imports gracefully, returning `None` or a default value if the module is not available.
- **Error Handling**: Detailed logging and error messages to aid in debugging import issues, including suggestions for missing packages.
## Advanced Property Descriptors
### Overview
Provides advanced property descriptors for Python classes, allowing the creation of instance, class, and mixed properties with optional caching capabilities. It includes decorators and base classes to facilitate the definition of properties that can behave differently depending on access context.
### Key Features
- **Custom Property Decorators**: Decorators like `@Property.Class` and `@Property.Cached` to define properties with custom behaviors.
- **Caching Support**: Ability to cache property results, optimizing performance for expensive computations.
- **Context-Aware Properties**: Properties that can differentiate between being accessed from an instance or a class.
- **Async Support**: Supports both synchronous and asynchronous property methods.
## Data Class Extensions and Configuration Handling
### Overview
Extends the standard `dataclass` module with additional features such as validation, serialization, dynamic class creation, and integration with custom logging mechanisms.
### Key Features
- **Custom Data Classes**: Enhanced `dataclass` decorator that supports extra parameters, memoization, and custom initialization.
- **Validation**: Automatic validation of field types and default values against the defined schema.
- **Serialization Methods**: Methods like `as_dict`, `as_json`, and `as_sql` for converting instances to different formats.
- **Dynamic Class Creation**: Utilities like `autoclass` and `simple` to generate classes dynamically based on configuration schemas.
- **Operator Overloading**: Overloaded operators (`&`, `|`, `^`, `-`, `+`) for combining and comparing data class instances.
## Serialization and Deserialization Utilities
### Overview
Provides advanced serialization and deserialization utilities, supporting multiple serialization backends, compression algorithms, and encoding schemes. It allows custom serialization of complex objects, automatic detection of serialization formats, and flexible data encoding and decoding options.
### Key Features
- **Multiple Backends**: Supports serialization backends like `orjson` and standard `json`, with automatic selection.
- **Custom Serialization**: Ability to register custom serialization functions for specific classes.
- **Compression Support**: Utilizes compression libraries like `zstd` or `gzip` to compress serialized data.
- **Flexible Encoding**: Supports multiple encoding schemes such as Base16, Base32, Base64, Base85, and Base2048.
- **Automatic Backend Detection**: Deserialization functions automatically detect the serialization backend used.
- **Error Handling**: Robust exception handling and context-aware suppression of errors.
Raw data
{
"_id": null,
"home_page": null,
"name": "kalib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "dataclass, decorators, descriptors, http, import, introspection, logging, python, serialization, string, utilities",
"author": null,
"author_email": "Alex Kalaverin <alex@kalaver.in>",
"download_url": "https://files.pythonhosted.org/packages/6b/00/e704233a7beca7ba94ad5b4bd7ccd28b9e85d9cce3522268b8c14f14a984/kalib-0.21.14.tar.gz",
"platform": null,
"description": "# Advanced Python Utilities Module\n\nThis module provides a comprehensive set of utilities for advanced Python programming, including HTTP communication, string handling, logging enhancements, introspection, dynamic importing, property descriptors, data class extensions, and serialization. It is designed to facilitate complex application development by offering robust tools that extend Python's standard capabilities.\n\n## Table of Contents\n\n- [HTTP Communication Utilities](#http-communication-utilities)\n- [String Handling Enhancements](#string-handling-enhancements)\n- [Advanced Logging System](#advanced-logging-system)\n- [Introspection and Reflection Utilities](#introspection-and-reflection-utilities)\n- [Dynamic Importing Tools](#dynamic-importing-tools)\n- [Advanced Property Descriptors](#advanced-property-descriptors)\n- [Data Class Extensions and Configuration Handling](#data-class-extensions-and-configuration-handling)\n- [Serialization and Deserialization Utilities](#serialization-and-deserialization-utilities)\n\n## HTTP Communication Utilities\n\n### Overview\n\nThis component provides a robust toolkit for handling HTTP communication. It includes advanced features for error handling, response parsing, cookie management, and URL processing. The utilities streamline building HTTP clients and services by abstracting common patterns and offering flexible, extensible components.\n\n### Key Features\n\n- **HTTPException Hierarchy**: A comprehensive set of exception classes for handling HTTP errors, based on status codes and error types.\n- **Response Handling**: Utilities for parsing and processing HTTP responses, including automatic JSON decoding and error checking.\n- **Cookie Management**: Tools for managing HTTP cookies, including parsing and formatting.\n- **URL Processing**: Classes and functions for manipulating URLs, including query parameters and path components.\n- **Serialization Decorators**: Decorators to facilitate serialization and deserialization of complex objects within the HTTP context.\n- **Namespace Augmentation**: Enhancements to the HTTP namespace for convenient access to common utilities like `HTTP.URL`, `HTTP.Agent`, and `HTTP.Exception`.\n\n## String Handling Enhancements\n\n### Overview\n\nProvides advanced string handling utilities focused on character encoding detection, conversion, and manipulation. It defines the `Str` class, acting as a wrapper around string or bytes objects, offering methods to handle various encoding scenarios and to facilitate text processing.\n\n### Key Features\n\n- **Encoding and Decoding**: Convert between bytes and string representations, handling different character encodings.\n- **Charset Detection**: Automatically detects the character encoding of input data using custom logic and libraries.\n- **Lazy Proxying**: Proxies common string methods to the underlying string representation, allowing `Str` instances to behave like regular strings.\n- **Tokenization**: Methods to split strings into tokens based on regular expression patterns.\n\n## Advanced Logging System\n\n### Overview\n\nEnhances the standard Python logging system by introducing custom log levels, additional logging utilities, and a more flexible logger configuration. It provides advanced logging capabilities suitable for complex applications that require detailed logging and traceability.\n\n### Key Features\n\n- **Custom Log Levels**: Defines additional log levels like `NOTICE`, `DEPRECATE`, and `VERBOSE` for finer-grained logging.\n- **Logger Configuration**: Supports configuration from files (e.g., `logging.toml`), environment variables, or default settings.\n- **Logger Extensions**: Provides a `Logger` class with enhanced methods for logging, including context-aware logging and deduplication of messages.\n- **Integration with Modules**: Automatically injects the custom logger into modules, ensuring consistent logging behavior across the application.\n\n## Introspection and Reflection Utilities\n\n### Overview\n\nOffers a collection of utility functions and classes for introspection, type checking, and reflection. It includes functions to analyze objects, their types, inheritance hierarchies, and modules.\n\n### Key Features\n\n- **Type Checking Functions**: Utilities like `is_callable`, `is_collection`, and `is_iterable` for checking object types.\n- **Inheritance Utilities**: Functions to iterate over an object's MRO, get attributes from superclasses, and analyze class hierarchies.\n- **Module and Object Inspection**: Tools to get the module of an object, its fully qualified name, source file, and other metadata.\n- **Stack Inspection**: Functions to analyze the call stack, filter stack traces, and determine stack frame offsets.\n\n## Dynamic Importing Tools\n\n### Overview\n\nProvides utilities for dynamic importing of modules and objects, with support for caching, handling optional dependencies, and enhanced error reporting.\n\n### Key Features\n\n- **Dynamic Importing**: Functions like `import_object` to import modules or objects by name at runtime.\n- **Caching Imports**: `cached_import` function to memoize imports and improve performance.\n- **Optional Dependencies**: `optional` function to handle optional imports gracefully, returning `None` or a default value if the module is not available.\n- **Error Handling**: Detailed logging and error messages to aid in debugging import issues, including suggestions for missing packages.\n\n## Advanced Property Descriptors\n\n### Overview\n\nProvides advanced property descriptors for Python classes, allowing the creation of instance, class, and mixed properties with optional caching capabilities. It includes decorators and base classes to facilitate the definition of properties that can behave differently depending on access context.\n\n### Key Features\n\n- **Custom Property Decorators**: Decorators like `@Property.Class` and `@Property.Cached` to define properties with custom behaviors.\n- **Caching Support**: Ability to cache property results, optimizing performance for expensive computations.\n- **Context-Aware Properties**: Properties that can differentiate between being accessed from an instance or a class.\n- **Async Support**: Supports both synchronous and asynchronous property methods.\n\n## Data Class Extensions and Configuration Handling\n\n### Overview\n\nExtends the standard `dataclass` module with additional features such as validation, serialization, dynamic class creation, and integration with custom logging mechanisms.\n\n### Key Features\n\n- **Custom Data Classes**: Enhanced `dataclass` decorator that supports extra parameters, memoization, and custom initialization.\n- **Validation**: Automatic validation of field types and default values against the defined schema.\n- **Serialization Methods**: Methods like `as_dict`, `as_json`, and `as_sql` for converting instances to different formats.\n- **Dynamic Class Creation**: Utilities like `autoclass` and `simple` to generate classes dynamically based on configuration schemas.\n- **Operator Overloading**: Overloaded operators (`&`, `|`, `^`, `-`, `+`) for combining and comparing data class instances.\n\n## Serialization and Deserialization Utilities\n\n### Overview\n\nProvides advanced serialization and deserialization utilities, supporting multiple serialization backends, compression algorithms, and encoding schemes. It allows custom serialization of complex objects, automatic detection of serialization formats, and flexible data encoding and decoding options.\n\n### Key Features\n\n- **Multiple Backends**: Supports serialization backends like `orjson` and standard `json`, with automatic selection.\n- **Custom Serialization**: Ability to register custom serialization functions for specific classes.\n- **Compression Support**: Utilizes compression libraries like `zstd` or `gzip` to compress serialized data.\n- **Flexible Encoding**: Supports multiple encoding schemes such as Base16, Base32, Base64, Base85, and Base2048.\n- **Automatic Backend Detection**: Deserialization functions automatically detect the serialization backend used.\n- **Error Handling**: Robust exception handling and context-aware suppression of errors.\n",
"bugtrack_url": null,
"license": "BSD License",
"summary": "A comprehensive set of advanced utilities for Python programming, e.g. HTTP communication, string handling, logging enhancements, introspection, dynamic importing, property caching descriptors, data class extensions, serialization, etc.",
"version": "0.21.14",
"project_urls": null,
"split_keywords": [
"dataclass",
" decorators",
" descriptors",
" http",
" import",
" introspection",
" logging",
" python",
" serialization",
" string",
" utilities"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9877da5ba5aa00332a3cb5878144a158001aec1bd0bb1c5fc399ce33770cc67d",
"md5": "7e89e1622c0742d4f42c16303def1fdc",
"sha256": "301d3383ec4b65aea4d3a9c6126a81543b0af4496fab3ce7d99976668cd5e9ed"
},
"downloads": -1,
"filename": "kalib-0.21.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7e89e1622c0742d4f42c16303def1fdc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 50040,
"upload_time": "2025-02-21T08:39:57",
"upload_time_iso_8601": "2025-02-21T08:39:57.531664Z",
"url": "https://files.pythonhosted.org/packages/98/77/da5ba5aa00332a3cb5878144a158001aec1bd0bb1c5fc399ce33770cc67d/kalib-0.21.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6b00e704233a7beca7ba94ad5b4bd7ccd28b9e85d9cce3522268b8c14f14a984",
"md5": "d930a461ccd3a7ef7dc9ccb147a72932",
"sha256": "b0ce4d41ca16a1eaeca5dd96c9db720e3521bd8cf991c48e449109cd722add8e"
},
"downloads": -1,
"filename": "kalib-0.21.14.tar.gz",
"has_sig": false,
"md5_digest": "d930a461ccd3a7ef7dc9ccb147a72932",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 47436,
"upload_time": "2025-02-21T08:40:00",
"upload_time_iso_8601": "2025-02-21T08:40:00.531073Z",
"url": "https://files.pythonhosted.org/packages/6b/00/e704233a7beca7ba94ad5b4bd7ccd28b9e85d9cce3522268b8c14f14a984/kalib-0.21.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-21 08:40:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "kalib"
}