def SMPPClientConfigBuild(fCallback):
    'Parse args and try to build a JCliSMPPClientConfig instance to pass it to fCallback'
    def parse_args_and_call_with_instance(self, *args, **kwargs):
        cmd = args[0]
        arg = args[1]

        # Empty line
        if cmd is None:
            return self.protocol.sendData()
        # Initiate JCliSMPPClientConfig with sessBuffer content
        if cmd == 'ok':
            if len(self.sessBuffer) == 0:
                return self.protocol.sendData('You must set at least connector id (cid) before saving !')

            connector = {}
            for key, value in self.sessBuffer.iteritems():
                connector[key] = value
            try:
                SMPPClientConfigInstance = JCliSMPPClientConfig(**connector)
                # Hand the instance to fCallback
                return fCallback(self, SMPPClientConfigInstance)
            except Exception, e:
                return self.protocol.sendData('Error: %s' % str(e))
        else:
            # Unknown key
            if cmd not in SMPPClientConfigKeyMap:
                return self.protocol.sendData('Unknown SMPPClientConfig key: %s' % cmd)

            try:
                # Buffer key for later SMPPClientConfig initiating
                SMPPClientConfigKey = SMPPClientConfigKeyMap[cmd]
                if isinstance(arg, str) and SMPPClientConfigKey not in SMPPClientConfigStringKeys:
                    self.sessBuffer[SMPPClientConfigKey] = castInputToBuiltInType(cmd, str2num(arg))
                else:
                    self.sessBuffer[SMPPClientConfigKey] = castInputToBuiltInType(cmd, arg)
            except Exception, e:
                return self.protocol.sendData('Error: %s' % str(e))

            return self.protocol.sendData()
    return parse_args_and_call_with_instance
dataset/ETHPy150Open jookies/jasmin/jasmin/protocols/cli/smppccm.py/SMPPClientConfigBuild/original