def __unicode__(self): """Return unicode representation of this data_element""" if isinstance(self.value, compat.text_type): # start with the string rep then replace the value part with the unicode strVal = str(self) uniVal = compat.text_type(strVal.replace(self.repval, "")) + self.value return uniVal else: return compat.text_type(str(self))
def __deepcopy__(self, memo): """Make correctly a deep copy of the object. Needed because of the overwritten __new__. """ name = compat.text_type(self).encode('utf8') new_person = PersonNameUnicode(name, 'utf8') memo[id(self)] = new_person for k, v in self.__dict__.items(): setattr(new_person, k, deepcopy(v, memo)) return new_person
def __copy__(self): """Correctly copy object. Needed because of the overwritten __new__. """ # no need to use the original encoding here - we just encode and # decode in utf-8 and set the original encoding later name = compat.text_type(self).encode('utf8') new_person = PersonNameUnicode(name, 'utf8') new_person.__dict__.update(self.__dict__) return new_person
def __deepcopy__(self, memo): """Make correctly a deep copy of the object. Needed because of the overwritten __new__. """ name = compat.text_type(self).encode('utf8') new_person = PersonNameUnicode(name, 'utf8') memo[id(self)] = new_person # no need for deepcopy call - all attributes are immutable new_person.__dict__.update(self.__dict__) return new_person
def recurse_tree(self, ds, parent, hide=False): """ order the dicom tags """ for data_element in ds: if isinstance(data_element.value, compat.text_type): ip = self.dsTreeView.AppendItem(parent, text=compat.text_type(data_element)) else: ip = self.dsTreeView.AppendItem(parent, text=str(data_element)) if data_element.VR == "SQ": for i, ds in enumerate(data_element.value): sq_item_description = data_element.name.replace(" Sequence", "") item_text = "%s %d" % (sq_item_description, i + 1) parentNodeID = self.dsTreeView.AppendItem(ip, text=item_text.rjust(128)) self.recurse_tree(ds, parentNodeID)
def recurse_tree(tree, dataset, parent, hide=False): for data_element in dataset: node_id = parent + "." + hex(id(data_element)) if isinstance(data_element.value, compat.text_type): tree.hlist.add(node_id, text=compat.text_type(data_element)) else: tree.hlist.add(node_id, text=str(data_element)) if hide: tree.hlist.hide_entry(node_id) if data_element.VR == "SQ": # a sequence for i, dataset in enumerate(data_element.value): item_id = node_id + "." + str(i + 1) sq_item_description = data_element.name.replace( " Sequence", "") # XXX not i18n item_text = "{0:s} {1:d}".format(sq_item_description, i + 1) tree.hlist.add(item_id, text=item_text) tree.hlist.hide_entry(item_id) recurse_tree(tree, dataset, item_id, hide=True)
def recurse_tree(tree, dataset, parent, hide=False): # order the dicom tags for data_element in dataset: node_id = parent + "." + hex(id(data_element)) if isinstance(data_element.value, compat.text_type): tree.hlist.add(node_id, text=compat.text_type(data_element)) else: tree.hlist.add(node_id, text=str(data_element)) if hide: tree.hlist.hide_entry(node_id) if data_element.VR == "SQ": # a sequence for i, dataset in enumerate(data_element.value): item_id = node_id + "." + str(i + 1) sq_item_description = data_element.name.replace(" Sequence", "") # XXX not i18n item_text = "{0:s} {1:d}".format(sq_item_description, i + 1) tree.hlist.add(item_id, text=item_text) tree.hlist.hide_entry(item_id) recurse_tree(tree, dataset, item_id, hide=True)