This module contains functions to create SIP package for the 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: | Path to the root directory. |
Return type: | str |
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: | Local path when root_dir is considered as root of FS. |
Return type: | str |
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: | Basename of the path. |
Return type: | str |
Calculate size of all files in path.
Parameters: | path (str) – Path to the directory. |
---|---|
Returns: | Size of the directory in bytes. |
Return type: | int |
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: | Dictionary ordered by priority table. |
Return type: | OrderedDict |
Compose info XML file.
Info example:
<?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>\data\Denik_zajatce_Sramek_CZ_v30f-font.epub</item>
</itemlist>
<checksum type="MD5" checksum="ce076548eaade33888005de5d4634a0d">
\MD5.md5
</checksum>
</info>
Parameters: | |
---|---|
Returns: | XML string. |
Return type: | str |