Skip to content

Commit f087d47

Browse files
committed
Fixed python3 tests
1 parent a7e3a9b commit f087d47

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.pyc
2+
kb.egg-info
23
__pycache__
34
build

example.py

100644100755
+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
import os
@@ -23,12 +23,7 @@
2323
print("RecordIdentifier: %s" % record.identifiers)
2424
print("Abstract: %s" % record.abstracts)
2525
print("Title: %s" % record.titles)
26-
27-
2826
oai_handler.DEBUG = True
2927
r = oai_handler.get(record.identifiers[0])
3028
for alto in r.alto:
3129
print("Fulltext: %s" % alto_to_text(alto))
32-
#print(alto)
33-
34-
print("*************************************\n\n")

kb/nl/api/oai.py

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def get(self, identifier):
9595
9696
:param identifier: Identifier to get from OAI server
9797
"""
98+
identifier = identifier.replace('http://resolver.kb.nl/resolve?urn=', '')
99+
98100
if self.current_set == "ANP":
99101
identifier = identifier.replace(':mpeg21', '')
100102
identifier = identifier.split(':')[0] + ':' + identifier

test/alto_to_text_test.py

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
import os
@@ -19,7 +19,7 @@ def alto_to_text_test():
1919
>>> data = fh.read()
2020
>>> fh.close()
2121
>>> alto_to_text(data).split('\\n')[2][:45]
22-
u' De Rijksradiocontroledienst heeft te UTRECHT'
22+
' De Rijksradiocontroledienst heeft te UTRECHT'
2323
"""
2424

2525
if __name__ == "__main__":

test/oai_test.py

100644100755
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import os
44
import sys
@@ -26,7 +26,7 @@ def oai_anp():
2626
>>> len(alto_records[0])
2727
90124
2828
>>> alto_to_text(alto_records[0]).split("\\n")[1][:27]
29-
u' RADIO 1 van 1 Ootober 1937'
29+
' RADIO 1 van 1 Ootober 1937'
3030
>>> image_record = record.image
3131
http://resolver.kb.nl/resolve?urn=anp:1937:10:01:1:mpeg21:image
3232
>>> len(image_record)
@@ -70,15 +70,15 @@ def oai_dpo():
7070
>>> records = oai.list_records("DPO") # doctest: +ELLIPSIS
7171
http://services.kb.nl/mdo/oai?verb=ListRecords&metadataPrefix=didl&set=DPO&resumptionToken...
7272
>>> records.identifiers[:3]
73-
['dpo:10007:mpeg21', 'dpo:10008:mpeg21', 'dpo:10009:mpeg21']
73+
['dpo:10012:mpeg21', 'dpo:10014:mpeg21', 'dpo:10015:mpeg21']
7474
>>> record = oai.get(records.identifiers[0])
75-
http://services.kb.nl/mdo/oai?verb=GetRecord&identifier=DPO:dpo:10007:mpeg21&metadataPrefix=didl
75+
http://services.kb.nl/mdo/oai?verb=GetRecord&identifier=DPO:dpo:10012:mpeg21&metadataPrefix=didl
7676
>>> alto_records = record.alto # doctest: +ELLIPSIS
77-
http://resolver.kb.nl/resolve?urn=dpo:10007:mpeg21:0001:alto http://...
77+
http://resolver.kb.nl/resolve?urn=dpo:10012:mpeg21:0001:alto http://...
7878
>>> len(alto_records[0])
79-
21634
79+
1739
8080
>>> record.title[:20]
81-
'Aanmerkingen, wegens'
81+
'De minagting der her'
8282
>>> record.contributor
8383
False
8484
>>> record.publisher
@@ -103,7 +103,7 @@ def oai_byvanck():
103103
>>> image = record.image
104104
http://imageviewer.kb.nl/ImagingService/imagingService?id=BYVANCKB:mimi_78d38:dl1_183r_min
105105
>>> len(image)
106-
109258
106+
109800
107107
"""
108108

109109
if __name__ == "__main__":

test/sru_test.py

100644100755
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
import os
@@ -11,15 +11,15 @@ def oai_anp():
1111
"""
1212
>>> from kb.nl.api import sru
1313
>>> from kb.nl.helpers import alto_to_text
14-
>>> sru.DEBUG=True
14+
>>> sru.DEBUG = True
1515
>>> response = sru.search("beatrix AND juliana AND Bernhard AND gelukwensen", "ANP")
1616
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=1&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
1717
>>> for record in response.records:
1818
... print(record.dates)
1919
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=1&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
20-
['1967/04/28 00:00:00']
21-
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=2&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
2220
['1968/09/25 00:00:00']
21+
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=2&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
22+
['1967/04/28 00:00:00']
2323
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=3&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
2424
['1966/02/21 00:00:00']
2525
run_query: https://jsru.kb.nl/sru/sru?version=1.2&maximumRecords=1&operation=searchRetrieve&startRecord=4&recordSchema=dcx&x-collection=ANP&query=beatrix%20AND%20juliana%20AND%20Bernhard%20AND%20gelukwensen
@@ -35,7 +35,7 @@ def oai_anp():
3535
>>> for i, record in enumerate(sorted(response.records)):
3636
... print(record.titles, record.dates)
3737
... break
38-
(['Zij die vielen zijn gevallen / J.A. Deelder ; [foto: Pieter van Oudheusden]'], ['[ca. 1990]'])
38+
['Zij die vielen zijn gevallen'] ['[ca. 1990]']
3939
"""
4040

4141

0 commit comments

Comments
 (0)