def _getLabelRenderType(self, label): """ Return the way to render each label. """ if xmipp.labelIsImage(label): return COL_RENDER_IMAGE labelType = xmipp.labelType(label) if labelType == xmipp.LABEL_BOOL: return COL_RENDER_CHECKBOX return COL_RENDER_TEXT
def _getLabelRenderType(self, label, md): """ Return the way to render each label. """ if xmipp.labelIsImage(label): value = md.getValue(label, md.firstObject()) if value.endswith('.vol'): return COL_RENDER_VOLUME return COL_RENDER_IMAGE labelType = xmipp.labelType(label) if labelType == xmipp.LABEL_BOOL: return COL_RENDER_CHECKBOX return COL_RENDER_TEXT
def writeToMd(self, md, objId): """ Set back row values to a metadata row. """ for label, value in self._labelDict.iteritems(): # TODO: Check how to handle correctly unicode type # in Xmipp and Scipion t = type(value) if t is unicode: value = str(value) if t is int and xmipp.labelType(label) == xmipp.LABEL_SIZET: value = long(value) try: md.setValue(label, value, objId) except Exception, ex: print >> sys.stderr, "XmippMdRow.writeToMd: Error writting value to metadata." print >> sys.stderr, " label: %s, value: %s, type(value): %s" % (label2Str(label), value, type(value)) raise ex
def writeToMd(self, md, objId): """ Set back row values to a metadata row. """ for label, value in self._labelDict.iteritems(): # TODO: Check how to handle correctly unicode type # in Xmipp and Scipion t = type(value) if t is unicode: value = str(value) if t is int and xmipp.labelType(label) == xmipp.LABEL_SIZET: value = long(value) try: md.setValue(label, value, objId) except Exception, ex: print >> sys.stderr, "XmippMdRow.writeToMd: Error writting value to metadata." print >> sys.stderr, " label: %s, value: %s, type(value): %s" % ( label2Str(label), value, type(value)) raise ex
def getLabelPythonType(label): """ From xmipp label to python variable type """ labelType = xmipp.labelType(label) return LABEL_TYPES.get(labelType, str)