1- ================================
2- Firebird base modules for Python
3- ================================
1+ # firebird-base
2+
3+ ## Firebird base modules for Python
4+
5+ [ ![ PyPI - Version] ( https://img.shields.io/pypi/v/firebird-base.svg )] ( https://pypi.org/project/firebird-base )
6+ [ ![ PyPI - Python Version] ( https://img.shields.io/pypi/pyversions/firebird-base.svg )] ( https://pypi.org/project/firebird-base )
7+ [ ![ Hatch project] ( https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg )] ( https://github.com/pypa/hatch )
48
59The firebird-base package is a set of Python 3 modules commonly used by ` Firebird Project ` _
610in various development projects (for example the firebird-driver or Saturnin). However, these
711modules have general applicability outside the scope of development for Firebird_ .
812
9- Common data types
10- =================
13+ -----
14+
15+ ** Table of Contents**
16+
17+ - [ Installation] ( #installation )
18+ - [ License] ( #license )
19+ - [ Introduction] ( #introduction )
20+ - [ Documentation] ( #documentation )
21+
22+ ## Installation
23+
24+ ``` console
25+ pip install firebird-base
26+ ```
27+
28+ ## License
29+
30+ ` firebird-base ` is distributed under the terms of the [ MIT] ( https://spdx.org/licenses/MIT.html ) license.
31+
32+ ## Introduction
33+
34+ ### Common data types
1135
1236The ` types ` module provides collection of classes and other types that are often used by
1337other library modules or applications.
1438
15- * Exception `Error ` that is intended to be used as a base class of all application-related
39+ - Exception ` Error ` that is intended to be used as a base class of all application-related
1640 errors. The important difference from ` Exception ` class is that ` Error ` accepts keyword
1741 arguments, that are stored into instance attributes with the same name.
18- * `Singleton ` base class for singletons.
19- * `Sentinel ` base class for named sentinel objects that provide meaningful `str ` and `repr `,
42+ - ` Singleton ` base class for singletons.
43+ - ` Sentinel ` base class for named sentinel objects that provide meaningful ` str ` and ` repr ` ,
2044 along with collection of predefined sentinels.
21- * `Distinct ` abstract base class for classes (incl. dataclasses) with distinct instances.
22- * Collection of `Enums ` and `custom string types `.
45+ - ` Distinct ` abstract base class for classes (incl. dataclasses) with distinct instances.
46+ - Collection of ` Enums ` and ` custom string types ` .
2347
24- Various collection types
25- ========================
48+ ### Various collection types
2649
2750The ` collections ` module provides data structures that behave much like builtin ` list ` and
2851` dict ` types, but with direct support of operations that can use structured data stored in
@@ -31,22 +54,21 @@ means.
3154
3255All containers provide next operations:
3356
34- * `filter ` and `filterfalse ` that return generator that yields items for which expr is
57+ - ` filter ` and ` filterfalse ` that return generator that yields items for which expr is
3558 evaluated as True (or False).
36- * `find ` that returns first item for which expr is evaluated as True, or default.
37- * `contains ` that returns True if there is any item for which expr is evaluated as True.
38- * `occurrence ` that returns number of items for which expr is evaluated as True.
39- * `all ` and `any ` that return True if expr is evaluated as True for all or any collection element(s).
40- * `report ` that returns generator that yields data produced by expression(s) evaluated on collection items.
59+ - ` find ` that returns first item for which expr is evaluated as True, or default.
60+ - ` contains ` that returns True if there is any item for which expr is evaluated as True.
61+ - ` occurrence ` that returns number of items for which expr is evaluated as True.
62+ - ` all ` and ` any ` that return True if expr is evaluated as True for all or any collection element(s).
63+ - ` report ` that returns generator that yields data produced by expression(s) evaluated on collection items.
4164
4265Individual collection types provide additional operations like splitting and extracting
4366based on expression etc.
4467
4568Expressions used by these methods could be strings that contain Python expression referencing
4669the collection item(s), or lambda functions.
4770
48- Data conversion from/to string
49- ==============================
71+ ### Data conversion from/to string
5072
5173While Python types typically support conversion to string via builtin ` str() ` function (and
5274custom ` __str__ ` methods), there is no symetric operation that converts string created by
@@ -58,57 +80,52 @@ Symetric string conversion is used by `firebird.base.config` module, notably by
5880extend the range of data types supported by these options by registering convertors for
5981required data types.
6082
61- Configuration definitions
62- =========================
83+ ### Configuration definitions
6384
6485Complex applications (and some library modules like ` logging ` ) could be often parametrized
6586via configuration. Module ` firebird.base.config ` provides a framework for unified structured
6687configuration that supports:
6788
68- * configuration options of various data type, including lists and other complex types
69- * validation
70- * direct manipulation of configuration values
71- * reading from (and writing into) configuration in `configparser ` format
72- * exchanging configuration (for example between processes) using Google protobuf messages
89+ - configuration options of various data type, including lists and other complex types
90+ - validation
91+ - direct manipulation of configuration values
92+ - reading from (and writing into) configuration in ` configparser ` format
93+ - exchanging configuration (for example between processes) using Google protobuf messages
7394
7495Additionally, the ` ApplicationDirectoryScheme ` abstract base class defines set of mostly
7596used application directories. The function ` get_directory_scheme() ` could be then used
7697to obtain instance that implements platform-specific standards for file-system location
7798for these directories. Currently, only "Windows", "Linux" and "MacOS" directory schemes
7899are supported.
79100
80- Memory buffer manager
81- =====================
101+ ### Memory buffer manager
82102
83103Module ` buffer ` provides a raw memory buffer manager with convenient methods to read/write
84104data of various data types.
85105
86- Hook manager
87- ============
106+ ### Hook manager
88107
89108Module ` hooks ` provides a general framework for callbacks and “hookable” events, that
90109supports multiple usage strategies.
91110
92- Context-based logging
93- =====================
111+ ### Context-based logging
94112
95113Module ` logging ` provides context-based logging system built on top of standard ` logging `
96114module.
97115
98116The context-based logging:
99117
100- * Adds context information (defined as combination of topic, agent and context string values)
118+ - Adds context information (defined as combination of topic, agent and context string values)
101119 into ` logging.LogRecord ` , that could be used in logging message.
102- * Adds support for f-string message format.
103- * Allows assignment of loggers to specific contexts. The `LoggingManager ` class maintains
120+ - Adds support for f-string message format.
121+ - Allows assignment of loggers to specific contexts. The ` LoggingManager ` class maintains
104122 a set of bindings between ` Logger ` objects and combination of ` agent ` , ` context ` and ` topic `
105123 specifications. It’s possible to bind loggers to exact combination of values, or whole
106124 sets of values using ` ANY ` sentinel. It means that is possible to assign specific Logger
107125 to log messages for particular agent in any context, or any agent operating in specific
108126 context etc.
109127
110- Trace/audit for class instances
111- ===============================
128+ ### Trace/audit for class instances
112129
113130Module ` trace ` provides trace/audit logging for functions or object methods through
114131context-based logging provided by ` logging ` module.
@@ -125,16 +142,14 @@ callables at runtime.
125142
126143Trace supports configuration based on ` firebird.base.config ` .
127144
128- Registry for Google Protocol Buffer messages and enums
129- ======================================================
145+ ### Registry for Google Protocol Buffer messages and enums
130146
131147Module ` protobuf ` provides central registry for Google Protocol Buffer messages and enums.
132148The generated ` *_pb2.py protobuf ` files could be registered using ` register_decriptor ` or
133149` load_registered ` function. The registry could be then used to obtain information about
134150protobuf messages or enum types, or to create message instances or enum values.
135151
136- Callback systems
137- ================
152+ ### Callback systems
138153
139154Module ` firebird.base.signal ` provides two callback mechanisms: one based on signals and
140155slots similar to Qt signal/slot, and second based on optional method delegation similar to
@@ -144,12 +159,6 @@ In both cases, the callback callables could be functions, instance or class meth
144159partials and lambda functions. The ` inspect ` module is used to define the signature for
145160callbacks, and to validate that only compatible callables are assigned.
146161
147- |donate |
148-
149- .. _Firebird : http://www.firebirdsql.org
150- .. _Firebird Project : https://github.com/FirebirdSQL
162+ ## Documentation
151163
152- .. |donate | image :: https://www.firebirdsql.org/img/donate/donate_to_firebird.gif
153- :alt: Contribute to the development
154- :scale: 100%
155- :target: https://www.firebirdsql.org/en/donate/
164+ The documentation for this package is available at [ https://firebird-base.readthedocs.io ] ( https://firebird-base.readthedocs.io )
0 commit comments