# Path: mcm/comparators.py
# def get_comparator(path):
#     if path.type == 'single':
#         return SingleElementComparator()
#     elif path.type == 'ordered':
#         return OrderedComparator()
#     elif path.type == 'uniquekey':
#         return UniqueKeyComparator(keys=path.keys)
# 
# Path: mcm/exceptions.py
# class ReadError(Exception):
#     '''
#     Exception raised when reading from master or slave occured.
#     '''
# 
# Path: mcm/librouteros/exceptions.py
# class ConnError( LibError ):
#     '''
#     Connection related errors.
#     '''


from types import MethodType
from logging import getLogger
from mcm.comparators import get_comparator
from mcm.exceptions import ReadError
from mcm.librouteros.exceptions import ConnError

def real_action(self, action, data):

    self.configurator.slave.write(data=data, path=self.path, action=action)


def no_action(self, action, data):
    pass






class Configurator:


    def __init__(self, master, slave):
        self.master = master
        self.slave = slave


    def run(self, paths):
        for path in paths:
            configurator = self.getPathConfigurator(path=path)
            try:
                configurator.run()
            except ReadError as error:
                msg = 'Failed to read {path} {reason}'.format(path=path.absolute, reason=error)
                logger.error(msg)

# Path: mcm/comparators.py
# def get_comparator(path):
#     if path.type == 'single':
#         return SingleElementComparator()
#     elif path.type == 'ordered':
#         return OrderedComparator()
#     elif path.type == 'uniquekey':
#         return UniqueKeyComparator(keys=path.keys)
# 
# Path: mcm/exceptions.py
# class ReadError(Exception):
#     '''
#     Exception raised when reading from master or slave occured.
#     '''
# 
# Path: mcm/librouteros/exceptions.py
# class ConnError( LibError ):
#     '''
#     Connection related errors.
#     '''


# Path: mcm/configurators.py
from types import MethodType
from logging import getLogger
from mcm.comparators import get_comparator
from mcm.exceptions import ReadError
from mcm.librouteros.exceptions import ConnError


def real_action(self, action, data):

    self.configurator.slave.write(data=data, path=self.path, action=action)


def no_action(self, action, data):
    pass






class Configurator:


    def __init__(self, master, slave):
        self.master = master
        self.slave = slave


    def run(self, paths):
        for path in paths:
            configurator = self.getPathConfigurator(path=path)
            try:
                configurator.run()
            except ReadError as error:
                msg = 'Failed to read {path} {reason}'.format(path=path.absolute, reason=error)
                logger.error(msg)

            except ConnError as error: