api submodule

Functions for interaction with URN:NBN API.

cz_urnnbn_api.api.is_valid_reg_code(reg_code='edep')

Check whether reg_code is valid registrar code.

Parameters:reg_code (str) – Producent’s registration code.
Returns:True, if the reg_code is valid.
Return type:bool
cz_urnnbn_api.api.iter_registrars()

Iterate over all registrars.

Yields:objRegistrar instance with basic informations.
cz_urnnbn_api.api.get_registrar_info(reg_code)

Get detailed informations about registrar with reg_code.

Parameters:reg_code (str) – Code identifier of registrar.
Returns:Registrar instance with all informations.
Return type:obj
cz_urnnbn_api.api.register_document_obj(xml_composer, reg_code='edep')

Register document in mode BY_RESOLVER - let the resolver give you URN:NBN code.

Parameters:
  • xml_composer (obj) – Instance of the MonographComposer.
  • reg_code (str, default settings.REG_CODE) – Registrar’s code.
Returns:

Instance of URN_NBN which contains assinged URN:NBN code.

Return type:

obj

cz_urnnbn_api.api.register_document(xml, reg_code='edep')

Register document in mode BY_RESOLVER - let the resolver give you URN:NBN code.

Parameters:
  • xml (str) – XML, which will be used for registration. See xml_composer for details.
  • reg_code (str, default settings.REG_CODE) – Registrar’s code.
Returns:

Instance of URN_NBN which contains assinged URN:NBN code.

Return type:

obj

cz_urnnbn_api.api.register_digital_instance_obj(urn_nbn, digital_instance)

Register digital_instance object as new digital instance of the document for given urn_nbn

Parameters:
  • urn_nbn (str) – URN:NBN identifier of registered document.
  • digital_instance (obj) – DigitalInstance instance.
Returns:

DigitalInstance with more informations.

Return type:

obj

cz_urnnbn_api.api.register_digital_instance(urn_nbn, url, digital_library_id, format=None, accessibility=None)

Compose and register new digital instance of document.

Parameters:
  • urn_nbn (str) – URN:NBN identifier of registered document.
  • url (str) – URL of the digital instance.
  • digital_library_id (str) – ID of the digital library.
  • format (str, def. None) – Format of the instance - pdf for example.
  • accessibility (str, def. None) – Is the registration neccessary to access this instance?
Returns:

DigitalInstance with more informations.

Return type:

obj

cz_urnnbn_api.api.get_digital_instances(urn_nbn)

Get list of DigitalInstance objects for given urn_nbn.

DigitalInstances are pointers to DigitalLibrary, where the instance of document is stored. There should be always a link to the document in url property.

Returns:DigitalInstance objects or blank list.
Return type:list
cz_urnnbn_api.api.get_urn_nbn_info(urn_nbn)

For given urn_nbn string, return parsed URN_NBN object.

Parameters:urn_nbn (str) – String.
Returns:URN_NBN object with additional info in properties.
Return type:obj
cz_urnnbn_api.api.get_full_urn_nbn_record(urn_nbn)

Return full record for given urn_nbn.

Warning

This function doesn’t yet return ORM data, just plain string.

Parameters:urn_nbn (str) – String.
Returns:XML with full informations about URN:NBN record.
Return type:str