示例#1
0
def createSIP(path, UUID=None, sip_type='SIP'):
    """
    Create a new SIP object for a SIP at the given path.

    :param str path: The current path of the SIP on disk. Can contain variables; see the documentation for ReplacementDict for supported names.
    :param str UUID: The UUID to be created for the SIP. If not specified, a new UUID will be generated using the version 4 scheme.
    :param str sip_type: A string representing the type of the SIP. Defaults to "SIP". The other value typically used is "AIC".

    :returns str: The UUID for the created SIP.
    """
    if UUID is None:
        UUID = str(uuid.uuid4())
    print("Creating SIP:", UUID, "-", path)
    sip = SIP(uuid=UUID, currentpath=path, sip_type=sip_type)
    sip.save()

    return UUID
示例#2
0
def test_mdtype():
    assert isinstance(load._mdtype(File()), MetadataAppliesToType)
    assert isinstance(load._mdtype(Transfer()), MetadataAppliesToType)
    assert isinstance(load._mdtype(SIP()), MetadataAppliesToType)

    class UnknownClass(object):
        pass

    with pytest.raises(TypeError) as excinfo:
        load._mdtype(UnknownClass())
    assert "Types supported: File, Transfer, SIP" in str(excinfo.value)
示例#3
0
def createSIP(path, UUID=None, sip_type="SIP", diruuids=False, printfn=print):
    """
    Create a new SIP object for a SIP at the given path.

    :param str path: The current path of the SIP on disk. Can contain variables; see the documentation for ReplacementDict for supported names.
    :param str UUID: The UUID to be created for the SIP. If not specified, a new UUID will be generated using the version 4 scheme.
    :param str sip_type: A string representing the type of the SIP. Defaults to "SIP". The other value typically used is "AIC".
    :param str diruuids: A boolean indicating whether the SIP should have UUIDs assigned to all of its subdirectories. This param is relevant in filesystem_ajax/views.py and clientScripts/createSIPfromTransferObjects.py.

    :returns str: The UUID for the created SIP.
    """
    if UUID is None:
        UUID = str(uuid.uuid4())
    printfn("Creating SIP:", UUID, "-", path)
    sip = SIP(uuid=UUID,
              currentpath=path,
              sip_type=sip_type,
              diruuids=diruuids)
    sip.save()

    return UUID