mfd-common-libs


Namemfd-common-libs JSON
Version 1.11.0 PyPI version JSON
download
home_pageNone
SummaryModule with common libraries and methods used in Modular Framework Design (MFD) ...
upload_time2025-07-09 07:51:42
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > [!IMPORTANT]  
> This project is under development. All source code and features on the main branch are for the purpose of testing or evaluation and not production ready.

# Common Libs
Module with common libs used in MFD modules.

## Supported classes:

### TimeoutCounter
Params:

* `timeout: float` - Time, after which bool(obj) will become True
* `first_check_start: bool` - If `True` - start counting from the first `bool(obj)` attempt,
                                  otherwise counting is started at object creation.
  
Representation:
* `bool(obj:TimeoutCounter)` returns `False` if timer last less than timeout and `True` if more.

### DisableLogger

Context manager to temporarily suppress log messages.

#### Usage

```python
from mfd_common_libs import DisableLogger

with DisableLogger():
    # do something
```

## Supported features:

### log_func_info

It's a decorator, which logs name and passed arguments to decorated method. Uses given logger
Params:
* `logger` - object of Logger
#### Usage

```python
import logging
from mfd_common_libs import log_func_info

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)


@log_func_info(logger)
def calling_someone(someone):
    pass

calling_someone('Adam')
```
logs `MODULE_DEBUG:__main__:Calling func: calling_someone with arguments: ['Adam']`

### os_supported

It's a decorator, which checks if OS of connected device is expected/supported. It can be used in implementation of modules.
Requires `Connection` object from `mfd_connect` as argument in function!

Params:
* handle OSName written as python arguments eg. `@os_supported(OSName.LINUX)` or `@os_supported(OSName.LINUX, OSName.WINDOWS)`

Raises `OSSupportedDecoratorError`if not found necessary 'connection' and `UnexpectedOSException` when OS is unexpected.
#### Usage
Usually usage:
```python
from mfd_common_libs import os_supported
from mfd_typing import OSName


class MyModule:
  """My module."""

    @os_supported(OSName.LINUX, OSName.WINDOWS, OSName.FREEBSD)
    def __init__(self, *, connection):
        self._conn = connection
```

When your class doesn't have implemented custom `__init__`, but uses from parent, you need to define `__init__` like as bottom:
```python
from mfd_common_libs import os_supported
from mfd_typing import OSName


class MyModule:
  """My module."""
  
    def __init__(self, *, connection):
        self._conn = connection
      
      
class MyModuleWithInherit(MyModule):
    """My child module."""
    
    __init__ = os_supported(OSName.LINUX)(MyModule.__init__)
    
    def some_method(self):
        pass
```
## Supported methods:
* `add_logging_level(level_name: str, level_value: int) -> None` - Add a new logging level to the `logging` module. Does nothing if logging name is already declared.
* `add_logging_group(level_group: LevelGroup) -> None` - Add all log levels related to the given group to the logging module.\
Basically, add all log levels which include LevelGroup substring.\
So for example `add_logging_group(LevelGroup.BL)` will add:
  * `log_levels.BL_STEP`
  * `log_levels.BL_INFO`
  * `log_levels.BL_DEBUG`

### Data Structures

```python
class LevelGroup(Enum):
    """Names of log levels' groups."""

    BL = auto()
    MFD = auto()
    TEST = auto()
```

### Supported Logging Levels
* `MODULE_DEBUG` log level should be used when any activity during debugging the module is worth logging.
* `CMD` log level should be used only for executed command line (ex. from mfd-connect execute_command method).
* `OUT` log level should be used only for logging output from executed command line (ex. from mfd-connect execute_command method).
* `TEST_PASS` log level should be used in test cases to provide information about test result.
* `TEST_FAIL` log level should be used in test cases to provide information about test result.
* `TEST_STEP` log level should be used in test cases to provide information on high level steps being performed.
* `TEST_INFO` log level should be used in test cases to provide additional information between step and debug.
* `TEST_DEBUG` log level should be used in test cases for debug information about steps performed.
* `BL_STEP` log level should be used in Business Logic to provide information on high level steps being performed.
* `BL_INFO` log level should be used in Business Logic to provide additional information between step and debug.
* `BL_DEBUG` log level should be used in Business Logic for debug information for steps performed.
* `MFD_STEP` log level should be used in MFDs to provide information on high level steps being performed.
* `MFD_INFO` log level should be used in MFDs to provide additional information between step and debug.
* `MFD_DEBUG` log level should be used in MFDs for debug information about steps performed and is preferred to MODULE_DEBUG.

### Supported Level Groups
* `LevelGroup.BL` includes:
  * `BL_STEP`
  * `BL_INFO`
  * `BL_DEBUG`
* `LevelGroup.MFD` includes:
  * `MFD_STEP`
  * `MFD_INFO`
  * `MFD_DEBUG`
  * `MODULE_DEBUG`
* `LevelGroup.TEST` includes:
  * `TEST_PASS`
  * `TEST_FAIL`
  * `TEST_STEP`
  * `TEST_INFO`
  * `TEST_DEBUG`

## OS supported:
* LINUX
* WINDOWS
* ESXI
* FREEBSD
* EFI shell support

## Issue reporting

If you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue [here](https://github.com/intel/mfd-common-libs/issues).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mfd-common-libs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "> [!IMPORTANT]  \n> This project is under development. All source code and features on the main branch are for the purpose of testing or evaluation and not production ready.\n\n# Common Libs\nModule with common libs used in MFD modules.\n\n## Supported classes:\n\n### TimeoutCounter\nParams:\n\n* `timeout: float` - Time, after which bool(obj) will become True\n* `first_check_start: bool` - If `True` - start counting from the first `bool(obj)` attempt,\n                                  otherwise counting is started at object creation.\n  \nRepresentation:\n* `bool(obj:TimeoutCounter)` returns `False` if timer last less than timeout and `True` if more.\n\n### DisableLogger\n\nContext manager to temporarily suppress log messages.\n\n#### Usage\n\n```python\nfrom mfd_common_libs import DisableLogger\n\nwith DisableLogger():\n    # do something\n```\n\n## Supported features:\n\n### log_func_info\n\nIt's a decorator, which logs name and passed arguments to decorated method. Uses given logger\nParams:\n* `logger` - object of Logger\n#### Usage\n\n```python\nimport logging\nfrom mfd_common_libs import log_func_info\n\nlogger = logging.getLogger(__name__)\nlogging.basicConfig(level=logging.DEBUG)\n\n\n@log_func_info(logger)\ndef calling_someone(someone):\n    pass\n\ncalling_someone('Adam')\n```\nlogs `MODULE_DEBUG:__main__:Calling func: calling_someone with arguments: ['Adam']`\n\n### os_supported\n\nIt's a decorator, which checks if OS of connected device is expected/supported. It can be used in implementation of modules.\nRequires `Connection` object from `mfd_connect` as argument in function!\n\nParams:\n* handle OSName written as python arguments eg. `@os_supported(OSName.LINUX)` or `@os_supported(OSName.LINUX, OSName.WINDOWS)`\n\nRaises `OSSupportedDecoratorError`if not found necessary 'connection' and `UnexpectedOSException` when OS is unexpected.\n#### Usage\nUsually usage:\n```python\nfrom mfd_common_libs import os_supported\nfrom mfd_typing import OSName\n\n\nclass MyModule:\n  \"\"\"My module.\"\"\"\n\n    @os_supported(OSName.LINUX, OSName.WINDOWS, OSName.FREEBSD)\n    def __init__(self, *, connection):\n        self._conn = connection\n```\n\nWhen your class doesn't have implemented custom `__init__`, but uses from parent, you need to define `__init__` like as bottom:\n```python\nfrom mfd_common_libs import os_supported\nfrom mfd_typing import OSName\n\n\nclass MyModule:\n  \"\"\"My module.\"\"\"\n  \n    def __init__(self, *, connection):\n        self._conn = connection\n      \n      \nclass MyModuleWithInherit(MyModule):\n    \"\"\"My child module.\"\"\"\n    \n    __init__ = os_supported(OSName.LINUX)(MyModule.__init__)\n    \n    def some_method(self):\n        pass\n```\n## Supported methods:\n* `add_logging_level(level_name: str, level_value: int) -> None` - Add a new logging level to the `logging` module. Does nothing if logging name is already declared.\n* `add_logging_group(level_group: LevelGroup) -> None` - Add all log levels related to the given group to the logging module.\\\nBasically, add all log levels which include LevelGroup substring.\\\nSo for example `add_logging_group(LevelGroup.BL)` will add:\n  * `log_levels.BL_STEP`\n  * `log_levels.BL_INFO`\n  * `log_levels.BL_DEBUG`\n\n### Data Structures\n\n```python\nclass LevelGroup(Enum):\n    \"\"\"Names of log levels' groups.\"\"\"\n\n    BL = auto()\n    MFD = auto()\n    TEST = auto()\n```\n\n### Supported Logging Levels\n* `MODULE_DEBUG` log level should be used when any activity during debugging the module is worth logging.\n* `CMD` log level should be used only for executed command line (ex. from mfd-connect execute_command method).\n* `OUT` log level should be used only for logging output from executed command line (ex. from mfd-connect execute_command method).\n* `TEST_PASS` log level should be used in test cases to provide information about test result.\n* `TEST_FAIL` log level should be used in test cases to provide information about test result.\n* `TEST_STEP` log level should be used in test cases to provide information on high level steps being performed.\n* `TEST_INFO` log level should be used in test cases to provide additional information between step and debug.\n* `TEST_DEBUG` log level should be used in test cases for debug information about steps performed.\n* `BL_STEP` log level should be used in Business Logic to provide information on high level steps being performed.\n* `BL_INFO` log level should be used in Business Logic to provide additional information between step and debug.\n* `BL_DEBUG` log level should be used in Business Logic for debug information for steps performed.\n* `MFD_STEP` log level should be used in MFDs to provide information on high level steps being performed.\n* `MFD_INFO` log level should be used in MFDs to provide additional information between step and debug.\n* `MFD_DEBUG` log level should be used in MFDs for debug information about steps performed and is preferred to MODULE_DEBUG.\n\n### Supported Level Groups\n* `LevelGroup.BL` includes:\n  * `BL_STEP`\n  * `BL_INFO`\n  * `BL_DEBUG`\n* `LevelGroup.MFD` includes:\n  * `MFD_STEP`\n  * `MFD_INFO`\n  * `MFD_DEBUG`\n  * `MODULE_DEBUG`\n* `LevelGroup.TEST` includes:\n  * `TEST_PASS`\n  * `TEST_FAIL`\n  * `TEST_STEP`\n  * `TEST_INFO`\n  * `TEST_DEBUG`\n\n## OS supported:\n* LINUX\n* WINDOWS\n* ESXI\n* FREEBSD\n* EFI shell support\n\n## Issue reporting\n\nIf you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue [here](https://github.com/intel/mfd-common-libs/issues).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Module with common libraries and methods used in Modular Framework Design (MFD) ...",
    "version": "1.11.0",
    "project_urls": {
        "Changelog": "https://github.com/intel/mfd-common-libs/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/intel/mfd",
        "Issues": "https://github.com/intel/mfd-common-libs/issues",
        "Repository": "https://github.com/intel/mfd-common-libs"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "05262825ff7d0ab17c652240984ae52b26bb9f3e245769f095a31ef3c755096c",
                "md5": "9c838062c2d48f63058d61e1581ec9af",
                "sha256": "c6c5501b0fcd8570c12a3a34ab61ba03a28c3033ff23f3ce8d55bb2679f77d85"
            },
            "downloads": -1,
            "filename": "mfd_common_libs-1.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c838062c2d48f63058d61e1581ec9af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 9788,
            "upload_time": "2025-07-09T07:51:42",
            "upload_time_iso_8601": "2025-07-09T07:51:42.485449Z",
            "url": "https://files.pythonhosted.org/packages/05/26/2825ff7d0ab17c652240984ae52b26bb9f3e245769f095a31ef3c755096c/mfd_common_libs-1.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-09 07:51:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "intel",
    "github_project": "mfd-common-libs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "mfd-common-libs"
}
        
Elapsed time: 0.99968s