Iterator
The iterator module provides classes for iterating over data retrieved from OAI-PMH services.
This module includes the BaseOAIIterator, an abstract base class that defines a standard interface for OAI-PMH data iteration, along with its specialized subclasses. Each subclass is tailored to handle specific types of data such as records, identifiers, or sets, ensuring efficient and structured access to OAI-PMH responses.
Classes:
Name | Description |
---|---|
BaseOAIIterator |
An abstract base class for creating iterators over OAI-PMH data. |
OAIResponseIterator |
Iterates over OAI responses, handling pagination and resumption tokens. |
OAIItemIterator |
Provides iteration over specific OAI items like records, identifiers, and sets. |
BaseOAIIterator
Bases: ABC
An abstract base class for iterators over various types of data aggregated through the OAI-PMH protocol.
This class provides a common interface and implementation for iterating over records, identifiers, and sets obtained via OAI-PMH. It handles OAI-PMH's resumption token mechanism, allowing seamless iteration over potentially large sets of data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scythe |
Scythe
|
The Scythe instance used to perform OAI-PMH requests. |
required |
query |
dict[str, str]
|
A dictionary of parameters specifying the details of the OAI-PMH request. |
required |
ignore_deleted |
bool
|
A boolean flag indicating whether to ignore deleted records in the iteration. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
scythe |
The Scythe instance handling OAI-PMH requests. |
|
query |
The parameters for OAI-PMH requests. |
|
ignore_deleted |
Indicates whether deleted records should be ignored. |
|
verb |
str
|
The OAI-PMH verb (e.g., 'ListRecords', 'ListIdentifiers') used in the request. |
oai_response |
OAIResponse | None
|
The most recent OAIResponse received from the OAI server. |
resumption_token |
ResumptionToken | None
|
The current resumption token, if any, for paginated results. |
Source code in src/oaipmh_scythe/iterator.py
OAIItemIterator
Bases: BaseOAIIterator
An iterator class for iterating over various types of OAI items aggregated via OAI-PMH.
This iterator is designed to handle the iteration of specific OAI items, such as records or sets, from a repository. It extends the functionality of the BaseOAIIterator to parse and yield individual items from the OAI-PMH responses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scythe |
Scythe
|
The Scythe instance used for making OAI-PMH requests. |
required |
query |
dict[str, str]
|
A dictionary of OAI-PMH request parameters. |
required |
ignore_deleted |
bool
|
A boolean indicating whether to ignore deleted records in the response. |
False
|
Source code in src/oaipmh_scythe/iterator.py
__iter__()
Iterate over individual OAI items from the response.
Go through the items in the OAI-PMH response, applying any necessary mapping and handling the exclusion of deleted records if specified. Automatically handle pagination through resumption tokens.
Yields:
Name | Type | Description |
---|---|---|
OAIItem |
OAIItem
|
The next OAI item (e.g., record, identifier, set) from the response. |
Source code in src/oaipmh_scythe/iterator.py
OAIResponseIterator
Bases: BaseOAIIterator
An iterator class for iterating over OAI responses obtained via the OAI-PMH protocol.
This iterator specifically handles the iteration of OAIResponse objects, allowing for seamless navigation through a sequence of responses returned by an OAI-PMH request. It utilizes the underlying mechanisms of the BaseOAIIterator, including handling of resumption tokens for paginated data.
Source code in src/oaipmh_scythe/iterator.py
__iter__()
Yield the next OAIResponse object from the server response sequence.
Enable the OAIResponseIterator to iterate over a series of OAIResponse objects, managing pagination with resumption tokens. Continue yielding responses until no more data is available from the server.
Yields:
Name | Type | Description |
---|---|---|
OAIResponse |
OAIResponse
|
The next available OAIResponse object in the sequence. |