mloesch / sickle

Sickle: OAI-PMH for Humans
Other
106 stars 42 forks source link

empty resumption token create an error in the client #4

Closed gaubert closed 9 years ago

gaubert commented 9 years ago

According to the XSD grammar it is possible to have an empty resumptionToken. This creates an exception in the client:

Traceback (most recent call last):
  File "oai-sickle.py", line 15, in <module>
    for rec in records:
  File "xxxxxxx\python-2.7.6\lib\site-packages\sickle\iterator.py", line 148, in next
    self._next_response()
  File "xxxxxxx\python-2.7.6\lib\site-packages\sickle\iterator.py", line 135, in _next_response
    super(OAIItemIterator, self)._next_response()
  File "xxxxxxx\python-2.7.6\lib\site-packages\sickle\iterator.py", line 89, in _next_response
    oaiexceptions, code[0].upper() + code[1:])(description)
BadArgument: Bad argument: metadataPrefix

Bad argument: metadataPrefix
<OAI-PMH xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<SCRIPT/>
<responseDate>2015-06-30T12:55:54Z</responseDate>
<request verb="ListIdentifiers" metadataPrefix="iso19139" from="2015-06-01T23:59:59Z" until="2015-06-28T23:59:59Z">xxxxxxxxxxxx</request>
<ListIdentifiers>
<header>
<identifier>xxxxxxxx</identifier>
<datestamp>2014-10-24T00:00:00Z</datestamp>
<setSpec>blah</setSpec>
</header>
<resumptionToken cursor="0" completeListSize="46"/>
</ListIdentifiers>

I have implemented a quick fix by just testing the existence of the token attribute in the resumption token itself. You might want to do it differently. 
mloesch commented 9 years ago

+1 and merged. I shortened your commit message a little though ;-)

gaubert commented 9 years ago

No problems. Thanks for this little nifty client.