Holding class
- class almapiwrapper.inventory.Holding(mms_id: str | None = None, holding_id: str | None = None, zone: str | None = None, env: Literal['P', 'S'] | None = 'P', bib: IzBib | None = None, data: XmlData | Element | None = None, create_holding: bool | None = False)
Bases:
RecordClass representing a holding object. Holdings are only in the IZ.
Several possibilities for building holdings: - ‘get_holdings’ method of IzBib object - Holding(mms_id, holding_id, zone, env) - Holding(bib=BibIz, holding_id=holding_id)
if no ‘holding_id’ is provided, but ‘data’ is provided and create_holding is True, then it creates a new holding.
- Variables:
holding_id – holding ID
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
bib – class:almapiwrapper.inventory.IzBib object
data –
almapiwrapper.record.XmlDataor etree.Element object, useful to force update a record from a backuperror – boolean indicating if an error occurred during the last operation
error_msg – string containing the error message if an error occurred during the last operation
api_base_url_bibs – base URL for bibs API calls
area – area of the API, here ‘Bibs’
format – format of the data xml for holdings
- Parameters:
mms_id – record mms_id
holding_id – holding ID
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
bib – class:almapiwrapper.inventory.IzBib object
data –
almapiwrapper.record.XmlDataor etree.Element object, useful to force create a new holding (if no ‘holding_id’ is provided and create_holding is True)create_holding – boolean, if True try to create a new holding (if no ‘holding_id’ is provided)
- static api_call(method: Literal['get', 'put', 'post', 'delete'], *args, **kwargs) Response | None
Static method to handle http errors. Quit the program after 3 failed tries
- Parameters:
method – ‘get’, ‘put’, ‘post’ or ‘delete’ according to the api method call
- static build_headers(data_format: Literal['json', 'xml'], zone: str, area: str, rights: Literal['R', 'RW'] = 'RW', env: Literal['P', 'S'] | None = 'P') Dict
Build the headers for the API calls.
- Parameters:
data_format – “json” or “xml”
zone – optional, if indicated allow to make the query in an other IZ
area – area of the record, bibs, users for example
rights – “R” for read only or “RW” for write and read rights
env – environment of the api call: ‘P’ for production, ‘S’ for sandbox
- Returns:
dict with the headers
- property callnumber: str | None
Property of the holding returning the callnumber
- Returns:
str containing callnumber
Note
If the record encountered an error, this method will be skipped.
- property data: Dict | Element | DataFrame | None
Property that get xml data with API call. If not available, make an api call
- Returns:
xml data, dictionary or pandas dataframe
- delete(force: bool | None = False) None
Delete holding
- Returns:
None
Note
If the record encountered an error, this method will be skipped.
- delete_items() None
Delete all items of the holding
- Returns:
None
Note
If the record encountered an error, this method will be skipped.
- static get_data_from_disk(mms_id: str, holding_id: str, zone: str) XmlData | None
Fetch the data of the described record
- Parameters:
mms_id – bib record mms_id
holding_id – holding record ID
zone – zone of the record
- Returns:
almapiwrapper.record.XmlDataor None
- get_holding_id() str
Fetch holding ID in the data of ‘data’ attribute.
Useful for creating a new holding.
- Returns:
str with holding id
Note
If the record encountered an error, this method will be skipped.
- get_items() List[Item]
Retrieve the list of items and loads the xml data of these items
To avoid reloading this information, the items references are stored in the private attribute ‘_items’.
- Returns:
list of
almapiwrapper.bib.Itemobjects
Note
If the record encountered an error, this method will be skipped.
- property library: str | None
Property of the holding returning the library code
- Returns:
str containing library code
- property location: str | None
Property of the holding returning the library code
- Returns:
str containing library code
Note
If the record encountered an error, this method will be skipped.
- static parse_data(data: JsonData | XmlData | Dict | str) JsonData | XmlData | None
Parse the data and return a parsed data object or None if an error occurs
- Parameters:
data – data to be parsed
- Returns:
parsed data object or None if an error occurs
- save() Holding
Save holding in a folder for each MMS ID
Example: records/UBS_9963486250105504/hol_22314215780005504_01.xml
- Returns:
almapiwrapper.inventory.Holdingobject
Note
If the record encountered an error, this method will be skipped.
- update() Holding
Update data of a holding
- Returns:
almapiwrapper.inventory.Holdingobject
Note
If the record encountered an error, this method will be skipped.