def toJSON(self, top=True): json = super(Canvas, self).toJSON(top) if json.has_key('images'): newimgs = [] for c in json['images']: newimgs.append(c.toJSON(False)) json['images'] = newimgs if json.has_key('otherContent'): newlists = [] for c in json['otherContent']: newlists.append(c.toJSON(False)) json['otherContent'] = newlists return json
def toJSON(self, top=True): json = super(Collection, self).toJSON(top) newcolls = [] newmans = [] if json.has_key('collections'): # Add in only @id, @type, label for c in json['collections']: newcolls.append({"@id": c.id, '@type': 'sc:Collection', 'label': c.label}) json['collections'] = newcolls if json.has_key('manifests'): # Add in only @id, @type, label for c in json['manifests']: newmans.append({"@id": c.id, '@type': 'sc:Manifest', 'label': c.label}) json['manifests'] = newmans return json
def toJSON(self, top=True): json = super(Manifest, self).toJSON(top) newseqs = [] for s in json['sequences']: newseqs.append(s.toJSON(False)) json['sequences'] = newseqs if json.has_key('structures'): newstructs = [] for s in json['structures']: newstructs.append(s.toJSON(False)) json['structures'] = newstructs return json
def toJSON(self, top=True): json = super(Collection, self).toJSON(top) newcolls = [] newmans = [] if json.has_key('collections'): # Add in only @id, @type, label for c in json['collections']: newcolls.append({ "@id": c.id, '@type': 'sc:Collection', 'label': c.label }) json['collections'] = newcolls if json.has_key('manifests'): # Add in only @id, @type, label for c in json['manifests']: newmans.append({ "@id": c.id, '@type': 'sc:Manifest', 'label': c.label }) json['manifests'] = newmans return json
def toJSON(self, top=True): json = super(Manifest, self).toJSON(top) newseqs = [] for s in json['sequences']: if isinstance(s, Sequence): newseqs.append(s.toJSON(False)) elif type(s) == dict and dict['@type'] == 'sc:Sequence': newseqs.append(s) else: raise MetadataError("Non-Sequence in Manifest['sequences']") json['sequences'] = newseqs if json.has_key('structures'): newstructs = [] for s in json['structures']: newstructs.append(s.toJSON(False)) json['structures'] = newstructs return json