Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
bloomonkey committed Apr 28, 2014
2 parents 6c6634d + 303182e commit 4255073
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion oaiharvest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__name__ = "OAI-PMH Harvester"
__package = "oaiharvest"
__all__ = ['harvest', 'metadata']
__version__ = "1.1.4"
__version__ = "1.1.5"
11 changes: 11 additions & 0 deletions oaiharvest/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""OAI-PMH Harvesting Exceptions."""


class OAIPMHHarvestException(Exception):
"""Base Class for OAI-PMH Harvesting Exceptions."""
pass


class NotOAIPMHBaseURLException(OAIPMHHarvestException):
"""URL is not an OAI-PMH base URL."""
pass
15 changes: 12 additions & 3 deletions oaiharvest/harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Distributed under the terms of the BSD 3-clause License
<http://opensource.org/licenses/BSD-3-Clause>.
"""
from __future__ import with_statement
from __future__ import with_statement, absolute_import

import logging
import os
Expand All @@ -56,8 +56,9 @@
from oaipmh.client import Client
from oaipmh.error import NoRecordsMatchError

from metadata import DefaultingMetadataRegistry, XMLMetadataReader
from registry import verify_database
from .exceptions import NotOAIPMHBaseURLException
from .metadata import DefaultingMetadataRegistry, XMLMetadataReader
from .registry import verify_database


class OAIHarvester(object):
Expand All @@ -75,6 +76,14 @@ def _listRecords(self, baseUrl, metadataPrefix="oai_dc", **kwargs):
# Add metatdataPrefix to args
kwargs['metadataPrefix'] = metadataPrefix
client = Client(baseUrl, metadata_registry)
# Check that baseUrl actually represents an OAI-PMH target
try:
client.identify()
except IndexError:
raise NotOAIPMHBaseURLException(
"{0} does not appear to be an OAI-PMH compatible base URL"
"".format(baseUrl)
)
# Check server timestamp granularity support
client.updateGranularity()
for record in client.listRecords(**kwargs):
Expand Down

0 comments on commit 4255073

Please sign in to comment.