def getController(uiType, control, defaultValue): if uiType in constructors: pmUiType = constructors[uiType][IDX_PM_TYPE] pmClass = constructors[uiType][IDX_PM_CLASS] return pmGetController(pmUiType, pmClass(control), defaultValue) else: message('Cannot create controller: Unknown controller type: {0}.'.format(str(uiType)))
def getController(uiType, control, defaultValue): if uiType in constructors: return constructors[uiType](control, defaultValue) else: message( 'Cannot create controller: Unknown controller type: {0}.'.format( str(uiType)))
def load(self): if not m.optionVar(exists=self.optVarName): return {} try: obj = json.loads(m.optionVar(q=self.optVarName)) except Exception as e: message('Error occurred while loading option variable {0}.\nAdditional exception info:\n{1}'.format(self.optVarName, str(e))) raise return obj
def getController(uiType, control, defaultValue): if uiType in constructors: pmUiType = constructors[uiType][IDX_PM_TYPE] pmClass = constructors[uiType][IDX_PM_CLASS] return pmGetController(pmUiType, pmClass(control), defaultValue) else: message( 'Cannot create controller: Unknown controller type: {0}.'.format( str(uiType)))
def load(self): if not m.optionVar(exists=self.optVarName): return {} try: obj = json.loads(m.optionVar(q=self.optVarName)) except Exception as e: message( 'Error occurred while loading option variable {0}.\nAdditional exception info:\n{1}' .format(self.optVarName, str(e))) raise return obj
def save(self, obj): try: m.optionVar(stringValue=( self.optVarName, json.dumps( obj, sort_keys=True, indent=4, separators=(',', ': ')))) except Exception as e: message( 'Error occurred while saving option variable {0}.\nAdditional exception info:\n{1}' .format(self.optVarName, str(e))) raise
def save(self, obj): try: f = open(self.filename, 'wb') try: self.saveProcedure(obj, f) finally: f.close() except IOError as e: message('Error writing file. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e))) raise except Exception as e: message('Error occurred during serialization. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e))) raise
def addControl(self, control, uiType, defaultValue=None): if not UIType.isTypeOf(uiType, UIType.TypesAll): message('Cannot add unknown control type ({0}) for {1}. Skipped'.format(uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesPYQT | UIType.TypesPYSIDE): controller = ctrl_qt.getController(uiType, control, defaultValue) if controller: self.controllers.append(controller) else: message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesM): if ctrl_maya: self.controllers.append(ctrl_maya.getController(uiType, control, defaultValue)) else: message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesPM): if ctrl_pymel: self.controllers.append(ctrl_pymel.getController(uiType, control, defaultValue)) else: message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control))) return assert False, 'Failed to add a controller.'
def addControl(self, control, uiType, defaultValue=None): if not UIType.isTypeOf(uiType, UIType.TypesAll): message('Cannot add unknown control type ({0}) for {1}. Skipped'. format(uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesPYQT | UIType.TypesPYSIDE): controller = ctrl_qt.getController(uiType, control, defaultValue) if controller: self.controllers.append(controller) else: message('Failed to add controller (type={0}) for {1}'.format( uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesM): if ctrl_maya: self.controllers.append( ctrl_maya.getController(uiType, control, defaultValue)) else: message('Failed to add controller (type={0}) for {1}'.format( uiType, str(control))) return if UIType.isTypeOf(uiType, UIType.TypesPM): if ctrl_pymel: self.controllers.append( ctrl_pymel.getController(uiType, control, defaultValue)) else: message('Failed to add controller (type={0}) for {1}'.format( uiType, str(control))) return assert False, 'Failed to add a controller.'
def getController(uiType, control, defaultValue): if uiType in constructors: if UIType.isTypeOf(uiType, UIType.TypesPYQT): if _PyQt4: return constructors[uiType](_PyQt4, control, defaultValue) else: message('Cannot create controller: PyQt is not available.') return if UIType.isTypeOf(uiType, UIType.TypesPYSIDE): if _PySide: return constructors[uiType](_PySide, control, defaultValue) else: message('Cannot create controller: PySide is not available.') return
def save(self, obj): try: f = open(self.filename, 'wb') try: self.saveProcedure(obj, f) finally: f.close() except IOError as e: message( 'Error writing file. Filename: {0}.\nAdditional exception info:\n{1}' .format(self.filename, str(e))) raise except Exception as e: message( 'Error occurred during serialization. Filename: {0}.\nAdditional exception info:\n{1}' .format(self.filename, str(e))) raise
def load(self): if not os.path.exists(self.filename): return {} try: f = open(self.filename, 'rb') try: obj = self.loadProcedure(f) finally: f.close() except IOError as e: message('Error reading file. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e))) raise except Exception as e: message('Error occurred during deserialization. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e))) raise return obj
def load(self): if not os.path.exists(self.filename): return {} try: f = open(self.filename, 'rb') try: obj = self.loadProcedure(f) finally: f.close() except IOError as e: message( 'Error reading file. Filename: {0}.\nAdditional exception info:\n{1}' .format(self.filename, str(e))) raise except Exception as e: message( 'Error occurred during deserialization. Filename: {0}.\nAdditional exception info:\n{1}' .format(self.filename, str(e))) raise return obj
def save(self, obj): try: m.optionVar(stringValue=(self.optVarName, json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': ')))) except Exception as e: message('Error occurred while saving option variable {0}.\nAdditional exception info:\n{1}'.format(self.optVarName, str(e))) raise
def getController(uiType, control, defaultValue): if uiType in constructors: return constructors[uiType](control, defaultValue) else: message('Cannot create controller: Unknown controller type: {0}.'.format(str(uiType)))