-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,63 @@ | ||
"""Test code for iiif_prezi.loader using remote data.""" | ||
|
||
import os | ||
import sys | ||
import optparse | ||
try: | ||
# python3 | ||
from urllib.request import urlopen | ||
except ImportError: | ||
# fall back to python2 | ||
from urllib2 import urlopen | ||
from iiif_prezi.loader import ManifestReader | ||
import urllib, os, sys | ||
|
||
def test_remote(): | ||
"""Test a list or remote Manifest URLs.""" | ||
urls = [ | ||
#"http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json", | ||
#"http://manifests.ydc2.yale.edu/manifest/Admont23.json", | ||
#"http://oculus-dev.lib.harvard.edu/manifests/drs:5981093", | ||
#"http://iiif-dev.bodleian.ox.ac.uk/metadata/bib_germ_1485_d1/bib_germ_1485_d1.json", | ||
#"http://iiif-dev.bodleian.ox.ac.uk/metadata/ms_auct_t_inf_2_1/ms_auct_t_inf_2_1.json", | ||
#"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest.json", | ||
#"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest-ranges.json", | ||
#"http://demos.biblissima-condorcet.fr/mirador/data/add_ms_10289_edited_8v-9r.json", | ||
#"http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b8438674r/manifest.json", | ||
"http://demos.biblissima-condorcet.fr/iiif/metadata/BVH/B410186201_LI03/manifest.json", | ||
"http://sanddragon.bl.uk/IIIFMetadataService/add_ms_10289.json", | ||
"http://sr-svx-93.unifr.ch/metadata/iiif/bbb-0218/manifest.json", | ||
#"http://www.shared-canvas.org/impl/demo1d/res/manifest.json" | ||
] | ||
for u in urls: | ||
fh = urllib.urlopen(u) | ||
data = fh.read() | ||
fh.close() | ||
try: | ||
print("------") | ||
print(u) | ||
reader = ManifestReader(data) | ||
nmfst = reader.read() | ||
js = nmfst.toJSON() | ||
except Exception as e: | ||
print(" => %s: %s" % (e.__class__.__name__, e)) | ||
|
||
|
||
TESTSET = [ | ||
# "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json", | ||
# "http://manifests.ydc2.yale.edu/manifest/Admont23.json", | ||
# "http://oculus-dev.lib.harvard.edu/manifests/drs:5981093", | ||
# "http://iiif-dev.bodleian.ox.ac.uk/metadata/bib_germ_1485_d1/bib_germ_1485_d1.json", | ||
# "http://iiif-dev.bodleian.ox.ac.uk/metadata/ms_auct_t_inf_2_1/ms_auct_t_inf_2_1.json", | ||
# "http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest.json", | ||
# "http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b84473026/manifest-ranges.json", | ||
# "http://demos.biblissima-condorcet.fr/mirador/data/add_ms_10289_edited_8v-9r.json", | ||
# "http://demos.biblissima-condorcet.fr/iiif/metadata/ark:/12148/btv1b8438674r/manifest.json", | ||
"http://demos.biblissima-condorcet.fr/iiif/metadata/BVH/B410186201_LI03/manifest.json", | ||
"http://sanddragon.bl.uk/IIIFMetadataService/add_ms_10289.json", | ||
"http://sr-svx-93.unifr.ch/metadata/iiif/bbb-0218/manifest.json", | ||
# "http://www.shared-canvas.org/impl/demo1d/res/manifest.json" | ||
] | ||
|
||
|
||
def read_args(): | ||
"""Read command line arguments.""" | ||
p = optparse.OptionParser(description='Check remote manifests by reading with iiif-prezi', | ||
usage='usage: %prog [options] [[url]] (-h for help)') | ||
p.add_option('--testset', '-t', action='store_true', | ||
help='Run against embedded testset') | ||
(opt, args) = p.parse_args() | ||
urls = list(args) | ||
if (opt.testset): | ||
urls.append(TESTSET) | ||
if (len(urls) == 0): | ||
raise Exception("Nothing to check (-h for help)") | ||
return(urls) | ||
|
||
|
||
def test_remote(urls): | ||
"""Test a list or remote Manifest URLs.""" | ||
for u in urls: | ||
fh = urlopen(u) | ||
data = fh.read() | ||
fh.close() | ||
try: | ||
print("------") | ||
print(u) | ||
reader = ManifestReader(data) | ||
nmfst = reader.read() | ||
js = nmfst.toJSON() | ||
except Exception as e: | ||
print(" => %s: %s" % (e.__class__.__name__, e)) | ||
|
||
if __name__ == "__main__": | ||
test_remote() | ||
test_remote(read_args()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"@context": "http://iiif.io/api/presentation/2/context.json", | ||
"@id": "http://example.org/testy-test-manifest", | ||
"@type": "sc:Manifest", | ||
"label": {"@language": "en", "@value": "Test Manifest"}, | ||
"metadata": [{"label": {"@language": "en", "@value": "Name"}, | ||
"value": {"@language": "en", "@value": "Jack"}}], | ||
"sequences": [ | ||
{ | ||
"@id": "http://example.org/iiif/book1/sequence/normal", | ||
"@type": "sc:Sequence", | ||
"label": "Current Page Order", | ||
"canvases": [ | ||
{ | ||
"@id": "http://example.org/iiif/book1/canvas/p1", | ||
"@type": "sc:Canvas", | ||
"label": "p. 1", | ||
"height":1000, | ||
"width":750, | ||
"images": [ | ||
{ | ||
"@type": "oa:Annotation", | ||
"motivation": "sc:painting", | ||
"resource":{ | ||
"@id": "http://example.org/iiif/book1/res/page1.jpg", | ||
"@type": "dctypes:Image", | ||
"format": "image/jpeg", | ||
"service": { | ||
"@context": "http://iiif.io/api/image/2/context.json", | ||
"@id": "http://example.org/images/book1-page1", | ||
"profile": "http://iiif.io/api/image/2/level1.json" | ||
}, | ||
"height":2000, | ||
"width":1500 | ||
}, | ||
"on": "http://example.org/iiif/book1/canvas/p1" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters