ats_utilities.factory_utils module

Module

factory_utils.py

Copyright

Copyright (C) 2017 - 2026 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 factory utils functions.

ats_utilities.factory_utils.cherry_pick_dict(source: dict[Any, Any] | None, keys: frozenset[str]) dict[Any, Any][source]

Cherry picks keys from a source dictionary.

Parameters:
  • source (<dict[Any, Any] | None>) – Source dictionary from which to pick keys | None.

  • keys (<frozenset[str]>) – Set of keys to pick from the source dictionary.

Returns:

Dictionary with cherry picked keys.

Return type:

<dict[Any, Any]>

Exceptions:

None.

ats_utilities.factory_utils.has_required_keys(source: dict[Any, Any] | None, keys: frozenset[str]) bool[source]

Checks if all required keys are present in the source dictionary.

Parameters:
  • source (<dict[Any, Any] | None>) – Source dictionary to check | None.

  • keys (<frozenset[str]>) – Set of mandatory keys.

Returns:

True (passed), False (failed).

Return type:

<bool>

Exceptions:

None.

ats_utilities.factory_utils.require_keys(source: dict[Any, Any] | None, keys: frozenset[str]) None[source]

Requires all keys to be present in the source dictionary.

Parameters:
  • source (<dict[Any, Any] | None>) – Source dictionary to check | None.

  • keys (<frozenset[str]>) – Set of mandatory keys.

Exceptions:

ATSTypeError, ATSValueError