# Path: mcm/librouteros/exceptions.py
# class CmdError( LibError ):
#     '''
#     Commend execution errors.
#     '''
# 
# Path: mcm/exceptions.py
# class ReadError(Exception):
#     '''
#     Exception raised when reading from master or slave occured.
#     '''
# 
# class WriteError(Exception):
#     '''
#     Exception raised when writing to master or slave occured.
#     '''


from posixpath import join as pjoin
from mcm.librouteros import CmdError
from mcm.exceptions import ReadError, WriteError


    def close(self):
        self.api.close()


    @staticmethod
    def cmd_action_join(path, action):
        actions = dict(ADD='add', SET='set', DEL='remove', GET='getall')
        return pjoin(path, actions[action])


    @staticmethod
    def filter_dynamic(data):
        return tuple(row for row in data if not row.get('dynamic'))


class RouterOsAPIDevice(ReadOnlyRouterOS):


    def write(self, path, action, data):
        command = self.cmd_action_join(path=path, action=action)
        method = getattr(self, action)
        method(command=command, data=data)


    def DEL(self, command, data):
        ID = {'.id':data['.id']}
        try:
            self.api.run(cmd=command, args=ID)

# Path: mcm/librouteros/exceptions.py
# class CmdError( LibError ):
#     '''
#     Commend execution errors.
#     '''
# 
# Path: mcm/exceptions.py
# class ReadError(Exception):
#     '''
#     Exception raised when reading from master or slave occured.
#     '''
# 
# class WriteError(Exception):
#     '''
#     Exception raised when writing to master or slave occured.
#     '''


# Path: mcm/iodevices.py
from posixpath import join as pjoin
from mcm.librouteros import CmdError
from mcm.exceptions import ReadError, WriteError



    def close(self):
        self.api.close()


    @staticmethod
    def cmd_action_join(path, action):
        actions = dict(ADD='add', SET='set', DEL='remove', GET='getall')
        return pjoin(path, actions[action])


    @staticmethod
    def filter_dynamic(data):
        return tuple(row for row in data if not row.get('dynamic'))


class RouterOsAPIDevice(ReadOnlyRouterOS):


    def write(self, path, action, data):
        command = self.cmd_action_join(path=path, action=action)
        method = getattr(self, action)
        method(command=command, data=data)


    def DEL(self, command, data):
        ID = {'.id':data['.id']}
        try:
            self.api.run(cmd=command, args=ID)

        except CmdError as error: