firebird-base


Namefirebird-base JSON
Version 1.7.1 PyPI version JSON
download
home_pageNone
SummaryFirebird base modules for Python
upload_time2023-10-08 11:38:33
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.8
license MIT License =========== Copyright (c) 2019 The Firebird Project (www.firebirdsql.org) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords collections configuration firebird hooks logging protobuf signals trace
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # firebird-base

## Firebird base modules for Python

[![PyPI - Version](https://img.shields.io/pypi/v/firebird-base.svg)](https://pypi.org/project/firebird-base)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/firebird-base.svg)](https://pypi.org/project/firebird-base)
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)

The firebird-base package is a set of Python 3 modules commonly used by [Firebird Project](https://github.com/FirebirdSQL)
in various development projects (for example the firebird-driver or Saturnin). However, these
modules have general applicability outside the scope of development for [Firebird](https://www.firebirdsql.org).

-----

**Table of Contents**

- [Installation](#installation)
- [License](#license)
- [Introduction](#introduction)
- [Documentation](#documentation)

## Installation

```console
pip install firebird-base
```

## License

`firebird-base` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

## Introduction

### Common data types

The `types` module provides collection of classes and other types that are often used by
other library modules or applications.

- Exception `Error` that is intended to be used as a base class of all application-related
  errors. The important difference from `Exception` class is that `Error` accepts keyword
  arguments, that are stored into instance attributes with the same name.
- `Singleton` base class for singletons.
- `Sentinel` base class for named sentinel objects that provide meaningful `str` and `repr`,
  along with collection of predefined sentinels.
- `Distinct` abstract base class for classes (incl. dataclasses) with distinct instances.
- Collection of `Enums` and `custom string types`.

### Various collection types

The `collections` module provides data structures that behave much like builtin `list` and
`dict` types, but with direct support of operations that can use structured data stored in
container, and which would normally require utilization of `operator`, `functools` or other
means.

All containers provide next operations:

- `filter` and `filterfalse` that return generator that yields items for which expr is
  evaluated as True (or False).
- `find` that returns first item for which expr is evaluated as True, or default.
- `contains` that returns True if there is any item for which expr is evaluated as True.
- `occurrence` that returns number of items for which expr is evaluated as True.
- `all` and `any` that return True if expr is evaluated as True for all or any collection element(s).
- `report` that returns generator that yields data produced by expression(s) evaluated on collection items.

Individual collection types provide additional operations like splitting and extracting
based on expression etc.

Expressions used by these methods could be strings that contain Python expression referencing
the collection item(s), or lambda functions.

### Data conversion from/to string

While Python types typically support conversion to string via builtin `str()` function (and
custom `__str__` methods), there is no symetric operation that converts string created by
`str()` back to typed value. Module `strconv` provides support for such symetric conversion
from/to string for any data type.

Symetric string conversion is used by `firebird.base.config` module, notably by
`firebird.base.config.ListOption` and `firebird.base.config.DataclassOption`. You can
extend the range of data types supported by these options by registering convertors for
required data types.

### Configuration definitions

Complex applications (and some library modules like `logging`) could be often parametrized
via configuration. Module `firebird.base.config` provides a framework for unified structured
configuration that supports:

- configuration options of various data type, including lists and other complex types
- validation
- direct manipulation of configuration values
- reading from (and writing into) configuration in `configparser` format
- exchanging configuration (for example between processes) using Google protobuf messages

Additionally, the `ApplicationDirectoryScheme` abstract base class defines set of mostly
used application directories. The function `get_directory_scheme()` could be then used
to obtain instance that implements platform-specific standards for file-system location
for these directories. Currently, only "Windows", "Linux" and "MacOS" directory schemes
are supported.

### Memory buffer manager

Module `buffer` provides a raw memory buffer manager with convenient methods to read/write
data of various data types.

### Hook manager

Module `hooks` provides a general framework for callbacks and “hookable” events, that
supports multiple usage strategies.

### Context-based logging

Module `logging` provides context-based logging system built on top of standard `logging`
module.

The context-based logging:

- Adds context information (defined as combination of topic, agent and context string values)
  into `logging.LogRecord`, that could be used in logging message.
- Adds support for f-string message format.
- Allows assignment of loggers to specific contexts. The `LoggingManager` class maintains
  a set of bindings between `Logger` objects and combination of `agent`, `context` and `topic`
  specifications. It’s possible to bind loggers to exact combination of values, or whole
  sets of values using `ANY` sentinel. It means that is possible to assign specific Logger
  to log messages for particular agent in any context, or any agent operating in specific
  context etc.

### Trace/audit for class instances

Module `trace` provides trace/audit logging for functions or object methods through
context-based logging provided by `logging` module.

The trace logging is performed by `traced` decorator. You can use this decorator directly,
or use `TracedMixin` class to automatically decorate methods of class instances on creation.
Each decorated callable could log messages before execution, after successful execution or
on failed execution (when unhandled exception is raised by callable). The trace decorator
can automatically add `agent` and `context` information, and include parameters passed to
callable, execution time, return value, information about raised exception etc. to log messages.

The trace logging is managed by `TraceManager`, that allows dynamic configuration of traced
callables at runtime.

Trace supports configuration based on `firebird.base.config`.

### Registry for Google Protocol Buffer messages and enums

Module `protobuf` provides central registry for Google Protocol Buffer messages and enums.
The generated `*_pb2.py protobuf` files could be registered using `register_decriptor` or
`load_registered` function. The registry could be then used to obtain information about
protobuf messages or enum types, or to create message instances or enum values.

### Callback systems

Module `firebird.base.signal` provides two callback mechanisms: one based on signals and
slots similar to Qt signal/slot, and second based on optional method delegation similar to
events in Delphi.

In both cases, the callback callables could be functions, instance or class methods,
partials and lambda functions. The `inspect` module is used to define the signature for
callbacks, and to validate that only compatible callables are assigned.

## Documentation

The documentation for this package is available at [https://firebird-base.readthedocs.io](https://firebird-base.readthedocs.io)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "firebird-base",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": "Collections,Configuration,Firebird,Hooks,Logging,Protobuf,Signals,Trace",
    "author": null,
    "author_email": "Pavel Cisar <pcisar@users.sourceforge.net>",
    "download_url": "https://files.pythonhosted.org/packages/b9/e9/46cc2f7deba763ae479d6a57375aa34b16c6428948d83d9c4bcfaa36c6f4/firebird_base-1.7.1.tar.gz",
    "platform": null,
    "description": "# firebird-base\n\n## Firebird base modules for Python\n\n[![PyPI - Version](https://img.shields.io/pypi/v/firebird-base.svg)](https://pypi.org/project/firebird-base)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/firebird-base.svg)](https://pypi.org/project/firebird-base)\n[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)\n\nThe firebird-base package is a set of Python 3 modules commonly used by [Firebird Project](https://github.com/FirebirdSQL)\nin various development projects (for example the firebird-driver or Saturnin). However, these\nmodules have general applicability outside the scope of development for [Firebird](https://www.firebirdsql.org).\n\n-----\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [License](#license)\n- [Introduction](#introduction)\n- [Documentation](#documentation)\n\n## Installation\n\n```console\npip install firebird-base\n```\n\n## License\n\n`firebird-base` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\n## Introduction\n\n### Common data types\n\nThe `types` module provides collection of classes and other types that are often used by\nother library modules or applications.\n\n- Exception `Error` that is intended to be used as a base class of all application-related\n  errors. The important difference from `Exception` class is that `Error` accepts keyword\n  arguments, that are stored into instance attributes with the same name.\n- `Singleton` base class for singletons.\n- `Sentinel` base class for named sentinel objects that provide meaningful `str` and `repr`,\n  along with collection of predefined sentinels.\n- `Distinct` abstract base class for classes (incl. dataclasses) with distinct instances.\n- Collection of `Enums` and `custom string types`.\n\n### Various collection types\n\nThe `collections` module provides data structures that behave much like builtin `list` and\n`dict` types, but with direct support of operations that can use structured data stored in\ncontainer, and which would normally require utilization of `operator`, `functools` or other\nmeans.\n\nAll containers provide next operations:\n\n- `filter` and `filterfalse` that return generator that yields items for which expr is\n  evaluated as True (or False).\n- `find` that returns first item for which expr is evaluated as True, or default.\n- `contains` that returns True if there is any item for which expr is evaluated as True.\n- `occurrence` that returns number of items for which expr is evaluated as True.\n- `all` and `any` that return True if expr is evaluated as True for all or any collection element(s).\n- `report` that returns generator that yields data produced by expression(s) evaluated on collection items.\n\nIndividual collection types provide additional operations like splitting and extracting\nbased on expression etc.\n\nExpressions used by these methods could be strings that contain Python expression referencing\nthe collection item(s), or lambda functions.\n\n### Data conversion from/to string\n\nWhile Python types typically support conversion to string via builtin `str()` function (and\ncustom `__str__` methods), there is no symetric operation that converts string created by\n`str()` back to typed value. Module `strconv` provides support for such symetric conversion\nfrom/to string for any data type.\n\nSymetric string conversion is used by `firebird.base.config` module, notably by\n`firebird.base.config.ListOption` and `firebird.base.config.DataclassOption`. You can\nextend the range of data types supported by these options by registering convertors for\nrequired data types.\n\n### Configuration definitions\n\nComplex applications (and some library modules like `logging`) could be often parametrized\nvia configuration. Module `firebird.base.config` provides a framework for unified structured\nconfiguration that supports:\n\n- configuration options of various data type, including lists and other complex types\n- validation\n- direct manipulation of configuration values\n- reading from (and writing into) configuration in `configparser` format\n- exchanging configuration (for example between processes) using Google protobuf messages\n\nAdditionally, the `ApplicationDirectoryScheme` abstract base class defines set of mostly\nused application directories. The function `get_directory_scheme()` could be then used\nto obtain instance that implements platform-specific standards for file-system location\nfor these directories. Currently, only \"Windows\", \"Linux\" and \"MacOS\" directory schemes\nare supported.\n\n### Memory buffer manager\n\nModule `buffer` provides a raw memory buffer manager with convenient methods to read/write\ndata of various data types.\n\n### Hook manager\n\nModule `hooks` provides a general framework for callbacks and \u201chookable\u201d events, that\nsupports multiple usage strategies.\n\n### Context-based logging\n\nModule `logging` provides context-based logging system built on top of standard `logging`\nmodule.\n\nThe context-based logging:\n\n- Adds context information (defined as combination of topic, agent and context string values)\n  into `logging.LogRecord`, that could be used in logging message.\n- Adds support for f-string message format.\n- Allows assignment of loggers to specific contexts. The `LoggingManager` class maintains\n  a set of bindings between `Logger` objects and combination of `agent`, `context` and `topic`\n  specifications. It\u2019s possible to bind loggers to exact combination of values, or whole\n  sets of values using `ANY` sentinel. It means that is possible to assign specific Logger\n  to log messages for particular agent in any context, or any agent operating in specific\n  context etc.\n\n### Trace/audit for class instances\n\nModule `trace` provides trace/audit logging for functions or object methods through\ncontext-based logging provided by `logging` module.\n\nThe trace logging is performed by `traced` decorator. You can use this decorator directly,\nor use `TracedMixin` class to automatically decorate methods of class instances on creation.\nEach decorated callable could log messages before execution, after successful execution or\non failed execution (when unhandled exception is raised by callable). The trace decorator\ncan automatically add `agent` and `context` information, and include parameters passed to\ncallable, execution time, return value, information about raised exception etc. to log messages.\n\nThe trace logging is managed by `TraceManager`, that allows dynamic configuration of traced\ncallables at runtime.\n\nTrace supports configuration based on `firebird.base.config`.\n\n### Registry for Google Protocol Buffer messages and enums\n\nModule `protobuf` provides central registry for Google Protocol Buffer messages and enums.\nThe generated `*_pb2.py protobuf` files could be registered using `register_decriptor` or\n`load_registered` function. The registry could be then used to obtain information about\nprotobuf messages or enum types, or to create message instances or enum values.\n\n### Callback systems\n\nModule `firebird.base.signal` provides two callback mechanisms: one based on signals and\nslots similar to Qt signal/slot, and second based on optional method delegation similar to\nevents in Delphi.\n\nIn both cases, the callback callables could be functions, instance or class methods,\npartials and lambda functions. The `inspect` module is used to define the signature for\ncallbacks, and to validate that only compatible callables are assigned.\n\n## Documentation\n\nThe documentation for this package is available at [https://firebird-base.readthedocs.io](https://firebird-base.readthedocs.io)\n",
    "bugtrack_url": null,
    "license": "\n        MIT License\n        ===========\n        \n        Copyright (c) 2019 The Firebird Project (www.firebirdsql.org)\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "Firebird base modules for Python",
    "version": "1.7.1",
    "project_urls": {
        "Documentation": "https://firebird-base.rtfd.io",
        "Funding": "https://github.com/sponsors/pcisar",
        "Home": "https://github.com/FirebirdSQL/python3-base",
        "Issues": "https://github.com/FirebirdSQL/python3-base/issues",
        "Source": "https://github.com/FirebirdSQL/python3-base"
    },
    "split_keywords": [
        "collections",
        "configuration",
        "firebird",
        "hooks",
        "logging",
        "protobuf",
        "signals",
        "trace"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e410fbec3f6b85ea7f45013dba4a91d42ea05702538d7503ecad597694ddbf72",
                "md5": "5dbf628304d11d9de67aaa903a70d7a2",
                "sha256": "55972fa2b839ab2219ab2d8033e5c13da5a4d57c3833e6c5a179b7fdce033333"
            },
            "downloads": -1,
            "filename": "firebird_base-1.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5dbf628304d11d9de67aaa903a70d7a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 61272,
            "upload_time": "2023-10-08T11:38:36",
            "upload_time_iso_8601": "2023-10-08T11:38:36.077691Z",
            "url": "https://files.pythonhosted.org/packages/e4/10/fbec3f6b85ea7f45013dba4a91d42ea05702538d7503ecad597694ddbf72/firebird_base-1.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b9e946cc2f7deba763ae479d6a57375aa34b16c6428948d83d9c4bcfaa36c6f4",
                "md5": "6401b1a3cbc815ae98f1416f6393ae3c",
                "sha256": "a20243ef540aa889db8684d02b501a7246f8c1e6c5951fd782a0c7832c682556"
            },
            "downloads": -1,
            "filename": "firebird_base-1.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6401b1a3cbc815ae98f1416f6393ae3c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 48720,
            "upload_time": "2023-10-08T11:38:33",
            "upload_time_iso_8601": "2023-10-08T11:38:33.458379Z",
            "url": "https://files.pythonhosted.org/packages/b9/e9/46cc2f7deba763ae479d6a57375aa34b16c6428948d83d9c4bcfaa36c6f4/firebird_base-1.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-08 11:38:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sponsors",
    "github_project": "pcisar",
    "github_not_found": true,
    "lcname": "firebird-base"
}
        
Elapsed time: 0.12647s