from factory import ManifestFactory BASEURL = "http://iiif.io/api/presentation/2.0/example/errors/" HOMEDIR = "../source/api/presentation/2.0/example/errors/" IMAGE_BASEURL = "http://iiif.io/api/image/2.0/example/" # Configure a factory for the fake Manifests fac = ManifestFactory() fac.set_base_metadata_uri(BASEURL) fac.set_base_metadata_dir(HOMEDIR) fac.set_base_image_uri(IMAGE_BASEURL) fac.set_iiif_image_info(2.0, 1) fac.set_debug('error') coll = fac.collection(label="Collection of Errors") TEST_ID = 0 mf = fac.manifest(label="manifest") s = mf.sequence() c = s.canvas(ident="c1", label="canvas") c.set_hw(1,1) basejs = mf.toJSON(top=True) anno = c.annotation() anno.image(ident="http://example.net/image.jpg", iiif=False) basejs_image = mf.toJSON(top=True) def make_test(data, name): global TEST_ID, BASEURL, HOMEDIR, coll
31: [addDetailImageIIIF], 32: [addDetailImage, addDetailImage], 33: [addDetailImage, makeDetailChoice], 34: [addDetailImage, makeDetailChoice, makeNilChoice], 35: [makePartialImage], 36: [makePartialImageIIIF], 37: [addDetailImage, makePartialDetail], 38: [addDetailImageIIIF, makePartialDetailIIIF], 39: [addRotation], 41: [addServerRotation] } manifests = {} coln = fac.collection(label="Collection of Test Cases") for (idn, info) in testInfo.items(): print "Building %s" % info['title'] # Build the Manifest mf = coln.manifest(ident="%s/manifest" % idn, label="Test %s Manifest: %s" % (idn, info['title'])) annolists = [] if info.has_key('mfprops'): for (p,v) in info['mfprops']: setattr(mf, p, v) for sx in range(info.get('nseqs', 1)): if sx > 0: seq = mf.sequence(ident="%s/s%s"%(idn, sx), label="Test %s Sequence %s" % (idn, sx+1)) else:
30: [addDetailImage], 31: [addDetailImageIIIF], 32: [addDetailImage, addDetailImage], 33: [addDetailImage, makeDetailChoice], 34: [addDetailImage, makeDetailChoice, makeNilChoice], 35: [makePartialImage], 36: [makePartialImageIIIF], 37: [addDetailImage, makePartialDetail], 38: [addDetailImageIIIF, makePartialDetailIIIF], 39: [addRotation], 41: [addServerRotation] } manifests = {} coln = fac.collection(label="Collection of Test Cases") for (idn, info) in testInfo.items(): print "Building %s" % info['title'] # Build the Manifest mf = coln.manifest(ident="%s/manifest" % idn, label="Test %s Manifest: %s" % (idn, info['title'])) annolists = [] if info.has_key('mfprops'): for (p, v) in info['mfprops']: setattr(mf, p, v) for sx in range(info.get('nseqs', 1)): if sx > 0: seq = mf.sequence(ident="%s/s%s" % (idn, sx),
'title': 'crm:P102_has_title ?t . ?t rdfs:label ?title' } qt = """ SELECT DISTINCT ?%s { <%s> %s } """ # Each object in the collection is a Manifest, with multiple images # Then we create a Collection for those Manifests sparql.setQuery(prefixes + q) results = sparql.query().convert() coll = fac.collection() for result in results["results"]["bindings"]: uri = result['obj']['value'] prefid = result['prefid']['value'] if not prefid.startswith(uri): continue # Terrible code, just fetches individual results thing = {'id': uri} # first get the images and check that they're not depicting more than one thing q2 = qt % ('image', uri, 'crm:P138i_has_representation ?image') sparql.setQuery(q2) imgres = sparql.query().convert() imagelist = []
from factory import ManifestFactory BASEURL = "http://iiif.io/api/presentation/2.0/example/errors/" HOMEDIR = "../source/api/presentation/2.0/example/errors/" IMAGE_BASEURL = "http://iiif.io/api/image/2.0/example/" # Configure a factory for the fake Manifests fac = ManifestFactory() fac.set_base_metadata_uri(BASEURL) fac.set_base_metadata_dir(HOMEDIR) fac.set_base_image_uri(IMAGE_BASEURL) fac.set_iiif_image_info(2.0, 1) fac.set_debug('error') coll = fac.collection(label="Collection of Errors") TEST_ID = 0 mf = fac.manifest(label="manifest") s = mf.sequence() c = s.canvas(ident="c1", label="canvas") c.set_hw(1, 1) basejs = mf.toJSON(top=True) anno = c.annotation() anno.image(ident="http://example.net/image.jpg", iiif=False) basejs_image = mf.toJSON(top=True) def make_test(data, name): global TEST_ID, BASEURL, HOMEDIR, coll
"title": "crm:P102_has_title ?t . ?t rdfs:label ?title", } qt = """ SELECT DISTINCT ?%s { <%s> %s } """ # Each object in the collection is a Manifest, with multiple images # Then we create a Collection for those Manifests sparql.setQuery(prefixes + q) results = sparql.query().convert() coll = fac.collection() for result in results["results"]["bindings"]: uri = result["obj"]["value"] prefid = result["prefid"]["value"] if not prefid.startswith(uri): continue # Terrible code, just fetches individual results thing = {"id": uri} # first get the images and check that they're not depicting more than one thing q2 = qt % ("image", uri, "crm:P138i_has_representation ?image") sparql.setQuery(q2) imgres = sparql.query().convert() imagelist = []
for t in st: strp = t.strip() if strp: nst.append(strp) subjs.append(', '.join(nst)) relDom = xpath(srcDom, './mods:relatedItem')[0] reltyp = xpath(relDom, './@type')[0] reltxt = xpath(relDom, './mods:titleInfo/mods:title/text()') mdhash = {"Identifier": uri, "Genre" : genre, "Place of Publication": place, "Publisher": publisher, "Frequency": freq, "Language": lang, reltyp : reltxt} # Make the top level collection coll = fac.collection(ident="top", label=label) coll.set_metadata(mdhash) coll.set_metadata({"label": "Rights", "value": [{"en": rdecl_en, "cy": rdecl_cy}]}) coll.set_description({"en": desc_en, "cy": desc_cy}) coll.set_metadata({"Subject" : subjs}) # And the structmap for issues issues = xpath(dom, '/mets:mets/mets:structMap//mets:div[@TYPE="ISSUE"]/mets:mptr/@xlink:href') # Make collection per year yearcolls = {} for issurl in issues: dom = fetch(issurl) date = xpath(dom, '/mets:mets/mets:dmdSec[@ID="dmdSec_MODS"]/mets:mdWrap/mets:xmlData/mods:mods/mods:part/mods:date/text()')[0]