# Path: zabby/core/exceptions.py
# class WrongArgumentError(Exception):
#     """ Wrong argument was passed to a function"""
# 
# Path: zabby/core/six.py
# def b(s):
#     return s.encode('utf-8')


import string
import struct
import logging
import sys
    import socketserver
    import SocketServer as socketserver
from zabby.core.exceptions import WrongArgumentError
from zabby.core.six import b


class DataSource:
    DEFAULT_VALUE = "ZBX_NOTSUPPORTED"

    def __init__(self, key_parser, config):
        self.key_parser = key_parser
        self.config = config

    def process(self, raw_key):
        """
        Calls function associated with raw_key and returns its result

        If function for raw_key is not present or wrong number of arguments
        is passed to it returns ZBX_NOTSUPPORTED
        """
        key, arguments = self.key_parser.parse(raw_key)
        LOG.debug("Received request for '{0}' with arguments {1}".format(
            key, arguments))

        function = None
        try:
            function = self.config.items[key]
        except KeyError:
            LOG.warning("Unknown key: {key}".format(key=key))

        value = self.DEFAULT_VALUE
        try:
            if function:
                value = function(*arguments)

# Path: zabby/core/exceptions.py
# class WrongArgumentError(Exception):
#     """ Wrong argument was passed to a function"""
# 
# Path: zabby/core/six.py
# def b(s):
#     return s.encode('utf-8')


# Path: zabby/agent.py
import string
import struct
import logging
import sys
    import socketserver
    import SocketServer as socketserver
from zabby.core.exceptions import WrongArgumentError
from zabby.core.six import b



class DataSource:
    DEFAULT_VALUE = "ZBX_NOTSUPPORTED"

    def __init__(self, key_parser, config):
        self.key_parser = key_parser
        self.config = config

    def process(self, raw_key):
        """
        Calls function associated with raw_key and returns its result

        If function for raw_key is not present or wrong number of arguments
        is passed to it returns ZBX_NOTSUPPORTED
        """
        key, arguments = self.key_parser.parse(raw_key)
        LOG.debug("Received request for '{0}' with arguments {1}".format(
            key, arguments))

        function = None
        try:
            function = self.config.items[key]
        except KeyError:
            LOG.warning("Unknown key: {key}".format(key=key))

        value = self.DEFAULT_VALUE
        try:
            if function:
                value = function(*arguments)

        except (TypeError, WrongArgumentError) as e: