Source code for aiida_phonopy.utils.mapping
# -*- coding: utf-8 -*-
"""Utilities to deal with various mapping data structures."""
[docs]def get_logging_container():
"""Return an `AttributeDict` that can be used to map logging messages to certain log levels.
This datastructure is useful to add log messages in a function that does not have access to the right logger. Once
returned, the caller who does have access to the logger can then easily loop over the contents and pipe the messages
through the actual logger.
:return: :py:class:`~aiida.common.extendeddicts.AttributeDict`
"""
from aiida.common import AttributeDict
return AttributeDict({
'debug': [],
'info': [],
'warning': [],
'error': [],
'critical': [],
})
[docs]def _lowercase_dict(dictionary: dict, dict_name: str):
"""Transform a dictionary to have the first keys decapitalized."""
return _case_transform_dict(dictionary, dict_name, '_lowercase_dict', str.lower)
[docs]def _uppercase_dict(dictionary: dict, dict_name: str):
"""Transform a dictionary to have the first keys capitalized."""
return _case_transform_dict(dictionary, dict_name, '_uppercase_dict', str.upper)