s3_start_transfer/src/archivematica.py
def find_matching_path(locations, bucket, directory, key):
    """
    Match the given bucket and key to a location and return a path on the
    Archivematica storage service

    This takes the form `<location_uuid>:<target_path>` where:
        `location_uuid` is the UUID of an S3 transfer source `Location` on the
        Archivematica storage service which is configured with the same
        bucket name and (optionally) a relative path that is a parent of the key
        `target_path` is the path of the key within the relative path

    e.g. a Location with bucket `test-bucket`, relative path '/test/path' and uuid 123 will match for
    bucket='test-bucket' and key='/test/path/subdir/file.zip'
    The return value will be '123:/subdir/file.zip'

    :param locations: Iterable of location dicts,
            each with `relative_path`, `s3_bucket` and `uuid` fields
    :param bucket: Name of s3 bucket
    :param key: Name of s3 key
    :returns: bytestring identifying the path
    """
    for location in locations:
        relative_path = location["relative_path"].strip("/")

        if relative_path == directory and location["s3_bucket"] == bucket:
            target_path = "/" + key
            return b"%s:%s" % (os.fsencode(location["uuid"]), os.fsencode(target_path))

    raise StoragePathException("Unable to find location for %s:%s" % (bucket, key))

    Match the given bucket and key to a location and return a path on the
    Archivematica storage service

    This takes the form `<location_uuid>:<target_path>` where:
        `location_uuid` is the UUID of an S3 transfer source `Location` on the
        Archivematica storage service which is configured with the same
        bucket name and (optionally) a relative path that is a parent of the key
        `target_path` is the path of the key within the relative path

    e.g. a Location with bucket `test-bucket`, relative path '/test/path' and uuid 123 will match for
    bucket='test-bucket' and key='/test/path/subdir/file.zip'
    The return value will be '123:/subdir/file.zip'

    :param locations: Iterable of location dicts,
            each with `relative_path`, `s3_bucket` and `uuid` fields
    :param bucket: Name of s3 bucket
    :param key: Name of s3 key
    :returns: bytestring identifying the path
    
Match the given bucket and key to a location and return a path on the
Archivematica storage service




Match the given bucket and key to a location and return a path on the Archivematica storage service
def find_matching_path(locations, bucket, directory, key):
    for location in locations:
        relative_path = location["relative_path"].strip("/")
        if relative_path == directory and location["s3_bucket"] == bucket:
            target_path = "/" + key
            return b"%s:%s" % (os.fsencode(location["uuid"]), os.fsencode(target_path))
    raise StoragePathException("Unable to find location for %s:%s" % (bucket, key))
def find_matching_path ( locations , bucket , directory , key ) : for location in locations : relative_path = location [ "relative_path" ] . strip ( "/" ) if relative_path == directory and location [ "s3_bucket" ] == bucket : target_path = "/" + key return b"%s:%s" % ( os . fsencode ( location [ "uuid" ] ) , os . fsencode ( target_path ) ) raise StoragePathException ( "Unable to find location for %s:%s" % ( bucket , key ) )
Match the given bucket and key to a location and return a path on the
Archivematica storage service
Match the given bucket and key to a location and return a path on the Archivematica storage service
"""
    Match the given bucket and key to a location and return a path on the
    Archivematica storage service

    This takes the form `<location_uuid>:<target_path>` where:
        `location_uuid` is the UUID of an S3 transfer source `Location` on the
        Archivematica storage service which is configured with the same
        bucket name and (optionally) a relative path that is a parent of the key
        `target_path` is the path of the key within the relative path

    e.g. a Location with bucket `test-bucket`, relative path '/test/path' and uuid 123 will match for
    bucket='test-bucket' and key='/test/path/subdir/file.zip'
    The return value will be '123:/subdir/file.zip'

    :param locations: Iterable of location dicts,
            each with `relative_path`, `s3_bucket` and `uuid` fields
    :param bucket: Name of s3 bucket
    :param key: Name of s3 key
    :returns: bytestring identifying the path
    """
bytestring identifying the path
bytestring identifying the path
locations
Iterable of location dicts,
each with `relative_path`, `s3_bucket` and `uuid` fields
Iterable of location dicts each with ` relative_path ` ` s3_bucket ` and ` uuid ` fields
bucket
Name of s3 bucket
Name of s3 bucket
directory
key
Name of s3 key
Name of s3 key