This module contains bindings to AMQP and also functions to create SIP package for LTP system.
Return package path. Use uuid to generate package’s directory name.
Parameters: | prefix (str) – Where the package will be stored. Default settings.TEMP_DIR. |
---|---|
Returns: | str – Path to the root directory. |
Create hierarchy of directories, at it is required in specification.
root_dir is root of the package generated using settings.TEMP_DIR and _get_package_name().
orig_dir is path to the directory, where the data files are stored.
metadata_dir is path to the directory with MODS metadata.
Parameters: | prefix (str) – Path to the directory where the root_dir will be stored. |
---|
Warning
If the root_dir exists, it is REMOVED!
Returns: | list of str – root_dir, orig_dir, metadata_dir |
---|
Return absolute path relative to root_dir.
When path == /home/xex/somefile.txt and root_dir == /home, returned path will be /xex/somefile.txt.
Parameters: |
|
---|---|
Returns: | str – Local path when root_dir is considered as root of FS. |
Name of the root directory is used as <packageid> in info.xml.
This function makes sure, that os.path.basename() doesn’t return blank string in case that there is / at the end of the path.
Parameters: | path (str) – Path to the root directory. |
---|---|
Returns: | str – Basename of the path. |
Calculate size of all files in path.
Parameters: | path (str) – Path to the directory. |
---|---|
Returns: | int – Size of the directory in bytes. |
Add order to unordered dict.
Order is taken from priority table, which is just something I did to make outputs from xmltodict look like examples in specification.
Parameters: | inp_dict (dict) – Unordered dictionary. |
---|---|
Returns: | OrderedDict – Dictionary ordered by priority table. |
Compose info XML file.
<?xml version=”1.0” encoding=”UTF-8” standalone=”yes”?> <info>
<created>2014-07-31T10:58:53</created> <metadataversion>1.0</metadataversion> <packageid>c88f5a50-7b34-11e2-b930-005056827e51</packageid> <mainmets>mets.xml</mainmets> <titleid type=”ccnb”>cnb001852189</titleid> <titleid type=”isbn”>978-80-85979-89-6</titleid> <collection>edeposit</collection> <institution>nakladatelství Altar</institution> <creator>ABA001</creator> <size>1530226</size> <itemlist itemtotal=”1”>
<item>dataDenik_zajatce_Sramek_CZ_v30f-font.epub</item></itemlist> <checksum type=”MD5” checksum=”ce076548eaade33888005de5d4634a0d”>
MD5.md5</checksum>
</info>
Parameters: |
|
---|---|
Returns: | str – XML string. |
Create LTP package as it is specified in specification v1.0 as I understand it.
Parameters: |
|
---|---|
Returns: | str – Name of the package’s directory in /tmp. |
React to given (AMQP) message. message is expected to be collections.namedtuple() structure from structures filled with all necessary data.
Parameters: |
|
---|---|
Returns: | object – Response class from structures. |
Raises: | ValueError – if bad type of message structure is given. |