def GroupBuild(fCallback):
    'Parse args and try to build a jasmin.routing.jasminApi.Group 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 jasmin.routing.jasminApi.Group with sessBuffer content
        if cmd == 'ok':
            if len(self.sessBuffer) != 1:
                return self.protocol.sendData('You must set Group id (gid) before saving !')

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

            # Buffer key for later Group initiating
            GroupKey = GroupKeyMap[cmd]
            self.sessBuffer[GroupKey] = arg

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