def __repr__(self): cls = self.__class__ try: sClsName = upperFirst(cls.classLabel) if hasattr(cls, "classLabel") else cls.__name__ sRepr = ("{0}('{1}')".format(sClsName, toStr(getattr(self, cls.classReprAttr)))) except AttributeError: sRepr = cls.__name__ return sRepr
def __repr__(self): cls = self.__class__ try: sClsName = upperFirst(cls.classLabel) if hasattr( cls, "classLabel") else cls.__name__ sRepr = ("{0}('{1}')".format( sClsName, toStr(getattr(self, cls.classReprAttr)))) except AttributeError: sRepr = cls.__name__ return sRepr
def _writeAllValues(self, propertyNames=None): logMsg(self.__class__.__name__, log='all') sPropertyIter = self.__class__._iterPropertyArg(propertyNames) for sProperty in sPropertyIter: value = getattr(self, sProperty) bWriteOnly = False sSetFnc = "set" + upperFirst(sProperty) setFnc = getattr(self, sSetFnc, None) msg = u"Setting {0}.{1} to {2}( {3} ) using {4}".format( self, sProperty, type(value).__name__, toStr(value), setFnc if setFnc else "setPrpty") logMsg(msg, log="debug") bSuccess = False if setFnc: try: bSuccess = setFnc(value, writingAttrs=True) except TypeError: try: bSuccess = setFnc(value) except Exception, msg: logMsg(msg, warning=True) bWriteOnly = True else: bWriteOnly = True if bWriteOnly: metaprpty = self.__metaProperties[sProperty] if metaprpty.isWritable(): bSuccess = metaprpty.write(value) else: logMsg(u"<{}> Writing to non-writable property: {}.{} .". format(getCaller(), self, metaprpty.name), warning=True) bSuccess = True if not bSuccess: logMsg("Failed " + lowerFirst(msg), warning=True)
def _writeAllValues(self, propertyNames=None): logMsg(self.__class__.__name__, log='all') sPropertyIter = self.__class__._iterPropertyArg(propertyNames) for sProperty in sPropertyIter: value = getattr(self, sProperty) bWriteOnly = False sSetFnc = "set" + upperFirst(sProperty) setFnc = getattr(self, sSetFnc, None) msg = u"Setting {0}.{1} to {2}( {3} ) using {4}".format( self, sProperty, type(value).__name__, toStr(value), setFnc if setFnc else "setPrpty") logMsg(msg, log="debug") bSuccess = False if setFnc: try: bSuccess = setFnc(value, writingAttrs=True) except TypeError: try: bSuccess = setFnc(value) except Exception, msg: logMsg(msg , warning=True) bWriteOnly = True else: bWriteOnly = True if bWriteOnly: metaprpty = self.__metaProperties[sProperty] if metaprpty.isWritable(): bSuccess = metaprpty.write(value) else: logMsg(u"<{}> Writing to non-writable property: {}.{} ." .format(getCaller(), self, metaprpty.name), warning=True) bSuccess = True if not bSuccess: logMsg("Failed " + lowerFirst(msg), warning=True)