Types
OaiRequest = ref object of RootObj base_url*: string oai_set*: string client: HttpClient
- This type describes an OAI request. Source Edit
Procs
proc newOaiRequest(url: string; oai_set = ""): OaiRequest {...}{.raises: [ValueError], tags: [].}
-
Constructs a new Oai-PMH request.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms")
Source Edit
Methods
method get_complete_size(this: OaiRequest; metadata_format: string): int {...}{.base, raises: [ ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError, ValueError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Gets the number of records in an OAI-PMH request.
If the request passes a resumptionToken, this parses size from resumptionToken[@completeListSize]. If the request does not have a resumption token, the value is based on the number of headers in the response.
- Requires:
- metadata_format(string): The metadata format of your request.
- Returns:
- int: The total number of records in a request.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler") x.get_complete_size("MODS")
Source Edit method list_sets(this: OaiRequest): seq[string] {...}{.base, raises: [ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns a sequence of sets as strings available from an OAI-PMH provider.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler") x.list_sets()
Source Edit method list_sets_and_descriptions(this: OaiRequest): seq[(string, string)] {...}{.base, raises: [ ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns a sequence of tuples with set name and set description available from an OAI-PMH provider.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler") x.list_sets_and_descriptions()
Source Edit method list_metadata_formats(this: OaiRequest): seq[string] {...}{.base, raises: [ ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns a sequence of metadata_formats available from an OAI-PMH provider.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler") x.list_metadata_formats()
Source Edit method identify(this: OaiRequest): string {...}{.base, raises: [ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns an XML file of information about an OAI-PMH provider as a string.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler") x.identify()
Source Edit method list_identifiers(this: OaiRequest; metadata_format: string; from_date: string = ""; until_date: string = ""): seq[string] {...}{. base, raises: [ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns a sequence of identifiers for records belonging to an OAI-PMH request.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms") x.list_identifiers("MODS")
Source Edit method harvest_metadata_records(this: OaiRequest; metadata_format: string; output_directory: string; from_date: string = ""; until_date: string = ""; identifier = false): (int, int) {...}{. base, raises: [ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect, ReadDirEffect, WriteDirEffect].}
-
Harvests metadata records from an OAI-PMH request to disk.
Requires:
metadata_format (string): The metadata format. output_directory (string): The full path to where you want to write your files.
Accepts:
from_date (string): Date from which to harvest until_date (string): Date to harvest until identifier (bool): Use header/identifier as value to serialize file to disk. Defaults to false and saves as an int.
Examples:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms") discard x.harvest_metadata_records("MODS", "/home/mark/nim_projects/oaitools/output")
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms") discard x.harvest_metadata_records("MODS", "/home/mark/nim_projects/oaitools/output", identifier=true)
Source Edit method list_records(this: OaiRequest; metadata_format: string; from_date: string = ""; until_date: string = ""): seq[string] {...}{.base, raises: [ ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns a sequence of XML records as strings for each record in a request.
NOTE: Use this method with caution. This can cause your sequence to get very big.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms") x.list_records("MODS")
Source Edit method get_record(this: OaiRequest; metadata_format: string; oai_identifier: string): string {...}{. base, raises: [ValueError, HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Defect, OverflowError, Exception, XmlError, RegexError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect, RootEffect].}
-
Returns an XML record as a string.
Example:
var x = newOaiRequest("https://dpla.lib.utk.edu/repox/OAIHandler", "utk_wderfilms") x.get_record("mods", "urn:dpla.lib.utk.edu.utk_comm:utkcomm_17456")
Source Edit