# 3-td party libraries from paho.mqtt.client import Client, MQTTMessage # Project modules from adapters import MQTTBrokerAdapter from storage import MongoDBStorageAdapter from utils.normalizers import DefaultNormalizer from config.utils import get_project_config # Logging section from utils.logs.tools import get_child_logger_by_name logger = get_child_logger_by_name(__name__) # Project configuration DEFAULT_CONFIG = get_project_config() # Default topics to subscribe TOPICS = [ "/clients", "/messages/#", ] class DataBroker: """ Class DataBroker This class is to encapsulate possible manipulations on data received from MQTT Message Broker and to specify callback function for registered get_topics. The class aggregate *MQTTBrokerAdapter* and *MongoDBStorageAdapter*.
import dateutil.parser import datetime # Project modules from config.utils import get_project_config from utils.validators import VALIDATOR_MAPPING, VALIDATOR_MESSAGE_TYPES from utils.tools import DateTimeDecoder # Logging section from utils.logs.tools import get_child_logger_by_name logger = get_child_logger_by_name(__name__) # Project configuration CONFIG = get_project_config() # Currently, allow only strings to be normalized ALLOWED_OBJECT_TYPES = (str, dict, bytes) class DefaultNormalizer: """ Class DefaultNormalizer Transforms serialized object into Python-comparable JSON object and check the validity of JSON scheme. Definitions ===== In Python a JSON object is presented as dictionary, so, let me call this as **JSON Python dictionary** """