def toString(self, compact=True): js = self.toJSON(top=True) if compact: return json.dumps(js, sort_keys=True, separators=(',', ':')) else: return json.dumps(js, sort_keys=True, indent=2)
fac = ManifestFactory() fac.set_base_metadata_uri("http://ids.lib.harvard.edu/iiif/metadata/") fac.set_base_image_uri("http://ids.lib.harvard.edu/ids/view/" + identifier + '/') fac.set_iiif_image_conformance(1.1, 1) # Build the Manifest mf = fac.manifest(ident="manifest", label=mflabel) mf.attribution = "Provided by the Houghton Library, Harvard University" mf.viewingHint = "paged" if manifestType == "PAGEDOBJECT" else "individuals" mf.description = "Description of Manuscript MS Richardson 44 Goes Here" # And walk through the pages seq = mf.sequence(ident="normal", label="Normal Order") for st in struct: # Find label, and image ID label = st.xpath('./@LABEL')[0] image = imageHash[st.xpath('./mets:div/mets:fptr[2]/@FILEID', namespaces=ALLNS)[0]] # Build the Canvas cvs = seq.canvas(ident="c%s" % image,label=label) cvs.set_hw(imageHeight, imageWidth) # Build the Image Annotation anno = cvs.annotation(ident="a%s" % image) img = anno.image(ident=image, iiif=True) img.set_hw(imageHeight, imageWidth) # Serialize mfjs = mf.toJSON() srlzd = json.dumps(mfjs, sort_keys=True, indent=2)
fac.set_base_image_uri("http://ids.lib.harvard.edu/ids/view/" + identifier + '/') fac.set_iiif_image_conformance(1.1, 1) # Build the Manifest mf = fac.manifest(ident="manifest", label=mflabel) mf.attribution = "Provided by the Houghton Library, Harvard University" mf.viewingHint = "paged" if manifestType == "PAGEDOBJECT" else "individuals" mf.description = "Description of Manuscript MS Richardson 44 Goes Here" # And walk through the pages seq = mf.sequence(ident="normal", label="Normal Order") for st in struct: # Find label, and image ID label = st.xpath('./@LABEL')[0] image = imageHash[st.xpath('./mets:div/mets:fptr[2]/@FILEID', namespaces=ALLNS)[0]] # Build the Canvas cvs = seq.canvas(ident="c%s" % image, label=label) cvs.set_hw(imageHeight, imageWidth) # Build the Image Annotation anno = cvs.annotation(ident="a%s" % image) img = anno.image(ident=image, iiif=True) img.set_hw(imageHeight, imageWidth) # Serialize mfjs = mf.toJSON() srlzd = json.dumps(mfjs, sort_keys=True, indent=2)
def do_info(self, identifier, date, edition, sequence): response["content_type"] = "application/json" js = self.make_info(identifier, date, edition, sequence) out = json.dumps(js, sort_keys=True, indent=2) return out