SruRecord
class
- class almasru.client.SruRecord(mms_id: str | None = None, xml: Element | None = None, base_url: str | None = None)
Class representing a single XML record from SRU
Either xml or mms_id must be provided. If mms_id is provided the constructor will fetch the record through SRU query.
- Variables:
mms_id – mms_id of the record to fetch
error – boolean, is True in case of error
error_messages – list of string with the error messages
warning – boolean, is True in case of warning
warning_messages – list of string containing the warning messages
sru_client –
almasru.client.SruClient
used to fetch the record
- get_035_fields(self, var: bool = False, slsp_only: bool = False) Set[str]
Return a set of system numbers of 035 fields
Note
Network ID inside 035 is simplified by removing prefix
- Parameters:
var – Parameters: flag indicating if truncated system numbers should be tested
slsp_only – Parameters: flag indicating if only slsp system numbers should be returned
- Returns:
Set of strings with the system IDs of 035 fields
- get_bib_level(self) Literal['a', 'b', 'c', 'd', 'i', 'm', 's']
Get the bib level of the record
Fetch the 7th position of the leader field.
- Returns:
str with the bib level
- get_child_analytical_records(self) List['SruRecord']
Get the list of analytical records. Check only existing 773 fields and not leader.
- Returns:
list of
almasru.client.SruRecord
- get_child_rec(self) Dict
check if the records appears in other records
Check system numbers and standard numbers to find records that are linked to the current record.
- Returns:
dictionary describing the result of analysis. Keys are following:
’MMS_ID’: current record ID
’related_records_found’: boolean indicating if related records have been found
’number_of_rel_recs’: number of related records found
’related_records’: list of
almasru.client.SruRecords
’fields_related_records’: list of fields.
- get_child_rec_std_num(self) Dict
Check if the given system number appears in other records.
- Return:
dictionary describing the result of analysis
- get_child_rec_sys_num(self) Dict
Check if the given system number appears in other records.
- Return:
dictionary describing the result of analysis
- get_child_removable_candidate_rec(self) List['SruRecord']
Get a list of child related records that are maybe removable
Fetch records containing specific field with link to the current record. Considered fields are ‘773’, ‘800’, ‘810’, ‘811’, ‘830’.
- Returns:
list of
almasru.client.SruRecord
- get_inventory_info(self) List[Dict]
Get information about the record in the IZ
The method analyse the 852 fields and returns a list with dictionaries containing: - “IZ”: IZ code - “MMS ID”: MMS ID of the record in the IZ - “format”: format of the record, “P” for print, “E” for electronic, “D” for digital
- Returns:
list of records in the IZ linked to the NZ record
- get_isbn(self) Set[str]
Fetch ISBN of the current record
Fetch the content of all 020$$a
- Returns:
set of ISBN
- get_issn(self) Set[str]
Fetch ISSN of the current record
Fetch the content of all 022$$a
- Returns:
set of ISSN
- get_iz_record(self, server_url: str) 'IzSruRecord' | None
Return
almasru.client.IzSruRecord
from provided server url- Parameters:
server_url – string with url of the IZ SRU server
- Returns:
Note
the function doesn’t work in all cases. It can only found records with inventory.
- get_iz_using_rec(self) List[str]
Get the list of IZ using this record
This method analyses the 852 fields and returns the list of IZ using the current NZ record.
- Returns:
list of IZ using this record.
- get_mms_id(self) str | None
Get MMS_ID of the current record
- Returns:
string containing the MMS_ID, None in case of error or no data available
- get_parent_rec(self) Dict
Get parents records of the current record
Uses the content of fields 7xx and 8xx to get all parent records. the method checks standard numbers in subfields “x” or “z” and system numbers in “w” subfield.
- Returns:
dictionary describing the result of the analysis
- get_parent_removable_candidate_rec(self) List['SruRecord']
Get a list of child related records that are maybe removable
Check 773 of the current record and look for potential parent records.
- Returns:
list of
almasru.client.SruRecord
- get_reasons_preventing_deletion(**kwargs)
analyse(self, removable_rec_mms_id: Optional[List[str]] = None) => List[str] Analyse the record to find reasons preventing deletion
- Parameters:
removable_rec_mms_id – list of MMS_ID of records that are safe to be removed. This is used to avoid records of the list currently being processed to be considered as preventing deletion.
- Returns:
list of string with the reasons preventing deletion
- get_standard_numbers(self) Set[str]
Fetch all ISSN and ISBN of the records
- Returns:
set of standard numbers
- is_removable(self, removable_rec_mms_id: List[str] | None = None) Tuple[bool, str]
Check if a record is safe to be removed
- Parameters:
removable_rec_mms_id – list of MMS_ID of records that are safe to be removed. This is used to avoid records of the list currently being processed to be considered as preventing deletion.
The method checks related records and inventory in IZ. 1. Test if the record has 852 fields. It would indicate existing holding in any IZ 2. Test if record has analytical records children (children linked with 773 field) 3. Test if the record is target of 8xx or 773 fields of other records 4. Test if the record has a 773 field targeting a record with inventory
- Returns:
tuple containing bool indicating if the record can be safely removed and a message.
- save(self) None
Save the xml data of the record in the ./records folder. Filename is rec_<mms_id>.xml
- Returns:
None