ats_utilities.checker package

Module contents

Module

__init__.py

Copyright

Copyright (C) 2017 - 2024 Vladimir Roncevic <elektron.ronca@gmail.com> ats_utilities is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ats_utilities is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Info

Defines class ATSChecker with attribute(s) and method(s). Creates an API for checking parameters for methods and functions.

class ats_utilities.checker.ATSChecker[source]

Bases: object

Defines class ATSChecker with attribute(s) and method(s). Creates an API for checking parameters for methods and functions. Mechanism for checking function or method parameters (type or format).

It defines:

attributes:
NO_ERROR - Marks no param error, error id (0).
TYPE_ERROR - Marks type param error, error id (1).
FORMAT_ERROR - Marks wrong format error, error id (2).
_start_message - Start segment of usage message.
_list_of_params - List of params for a method or function.
_error_type - List of mapped errors.
_error_type_index - Error type index.
methods:
__init__ - Initials ATSChecker constructor.
collect_params - Collects all params in one list.
usage_message - Prepares usage for method or function.
check_types - Checks params (types) for method or function.
priority_error - Sets priority error id (TYPE_ERROR).
check_params - Checks params for method or function.
FORMAT_ERROR: int = 2
NO_ERROR: int = 0
TYPE_ERROR: int = 1
check_params(params_desc: List[Tuple[str, Any]]) Tuple[str | None, int | None][source]

Checks params for method or function.

Parameters:

params_desc (<List[Tuple[str, Any]]>) – Description for params

Returns:

error message, error id (0 | 1 | 2)

Return type:

<str> | <NoneType>, <int> | <NoneType>

Exceptions:

None

check_types(params_desc: OrderedDict[str, Any]) bool[source]

Checks params (types) for method or function.

Parameters:

params_desc (<OrderedDict[str, Any]>) – Description for params

Returns:

True (type(s) is(are) ok) | False (type(s) is(are) not ok)

Return type:

<bool>

Exceptions:

None

collect_params(params_desc: OrderedDict[str, Any]) bool[source]

Collects all params in one list.

Parameters:

params_desc (<OrderedDict[str, Any]>) – Description for params

Returns:

True (are collected) | False (failed to collect)

Return type:

<bool>

Exceptions:

None

priority_error() int | None[source]

Sets priority error id (TYPE_ERROR).

Returns:

Priority error id (0 | 1 | 2) | None

Return type:

<int> | <NoneType>

Exceptions:

None

usage_message() str | None[source]

Prepares usage for method or function.

Returns:

Usage message for method or function | None

Return type:

<str> | <NoneType>

Exceptions:

None