SruClient class
- class almasru.client.SruClient(base_url: str | None = None, is_iz_server: bool | None = None)
Class representing an SRU server
This class is mostly used at the beginning of a process to set the base url of the SRU server.
Note
it is possible to change the base url to connect to another SRU server, but the already fetched records and requests are stored at the class level. They need to be reset.
- Variables:
nsmap – dict describing the name spaces used in records
parser – etree.XMLParser used to parse records
records – MMS ID as key and etree.Element of the Marc XML of the record as value
requests – dict with query__limit pattern as key and
almasru.client.SruRequestas valuebase_url – base url of the SRU server
is_iz_server – flag indicating if the SRU server is related to an IZ. Useful to get
almasru.client.IzSruRecordinstead ofalmasru.client.SruRecord
- classmethod clean_old_requests() None
Delete and recreate the requests folder and reset the requests and records attributes
- fetch_records(query: str, limit: int = 10) SruRequest
Fetch records with SRU
- Parameters:
query – string containing the sru query
limit – int indicating the max number of records to fetch, 10 is the default value
- Returns:
almasru.client.SruRequest
- classmethod set_base_url(base_url: str) None
Set the base url of the SRU client
It is required to set this parameter before using the client
- Parameters:
base_url – base url of the SRU server