"""Lambda shared module.""" from boto3.dynamodb.types import TypeDeserializer from src import config def parse_aws_dict(aws_dict): """Convert AWS dict to normal python typed dict. Args: aws_dict (dict): AWS dict like: {'order_id': {'S': '2000'}} Returns: dict: normal python typed dict like: {'order_id': '2000'} """ config.logger.debug( 'Parsing AWS dictionary like object %s', aws_dict) deser = TypeDeserializer() parsed_dict = {} for key, value in aws_dict.items(): parsed_dict[key] = deser.deserialize(value) config.logger.debug('Parsed into dictionary: %s', parsed_dict) return parsed_dict