def set_media_version(self, versions): self.version_set = True if len(versions) == 0: return list() type_names = self['Version'].childNames() # should maybe be sorted later when in step for obj in versions: if obj.version_type not in type_names: g = GenTree() g.setName(obj.version_type) self['Version'].addChild(g) type_names = self['Version'].childNames() self['Version'][obj.version_type].addChild(obj) return self.get_media_version()
def set_media_version2(self, versions, with_belong=True): self.version_set = True if len(versions) == 0: return list() type_names = self['Version'].childNames() # should maybe be sorted later when in step for obj in versions: if with_belong: key = obj.get_belong_to() else: key = obj.version_type if key not in type_names: g = GenTree() g.setName(key) self['Version'].addChild(g) type_names = self['Version'].childNames() self['Version'][key].addChild(obj) return self.get_media_version()