def setFds(self, fds): nfds = AIFds() for key in fds: func = getattr(nfds, 'set' + AIStrUtils.toUpperF(key)) if AIUtils.isFunc(func): apply(func, [fds[key]]) self.__fds = nfds
def setFields(self, fields): nflds = [] if not AIUtils.isEmpty(fields) and AIUtils.isList(fields): for fld in fields: nfld = AIFld() for key in fld: func = getattr(nfld, 'set' + AIStrUtils.toUpperF(key)) if AIUtils.isFunc(func): apply(func, [fld[key]]) nflds.append(nfld) self.__fields = nflds
def fromStr(self, attrs): obj = None if AIUtils.isStr(attrs): attrs = AIUtils.str2dict(attrs) obj = self if AIUtils.isDict(attrs): for key in attrs: func = getattr(obj, 'set' + AIStrUtils.toUpperF(key)) if AIUtils.isFunc(func): apply(func, [attrs[key]]) else: raise Exception('input parameter type not correct!') return obj