ObjectManager

class ltdconveyor.s3.ObjectManager(session, bucket_name, bucket_root)

Bases: object

Manage objects existing in a bucket under a specific bucket_root.

The ObjectManager maintains information about objects that exist in the bucket, and can delete objects that no longer exist in the source.

Parameters:
  • session (boto3.session.Session) – A boto3 session instance provisioned with the correct identities.

  • bucket_name (str) – Name of the S3 bucket.

  • bucket_root (str) – The version slug is the name root directory in the bucket where documentation is stored.

Methods Summary

delete_directory(dirname)

Delete a directory (and contents) from the bucket.

delete_file(filename)

Delete a file from the bucket.

list_dirnames_in_directory(dirname)

List all names of directories that exist at the root of this bucket directory.

list_filenames_in_directory(dirname)

List all file-type object names that exist at the root of this bucket directory.

Methods Documentation

delete_directory(dirname)

Delete a directory (and contents) from the bucket.

Parameters:

dirname (str) – Name of the directory, relative to bucket_root/.

Raises:

RuntimeError – Raised when there are no objects to delete (directory does not exist).

Return type:

None

delete_file(filename)

Delete a file from the bucket.

Parameters:

filename (str) – Name of the file, relative to bucket_root/.

Return type:

None

list_dirnames_in_directory(dirname)

List all names of directories that exist at the root of this bucket directory.

Note that directories don’t exist in S3; rather directories are inferred from path names.

Parameters:

dirname (str) – Directory name in the bucket relative to bucket_root.

Returns:

dirnames – List of directory names (str), relative to bucket_root/, that exist at the root of dirname.

Return type:

list

list_filenames_in_directory(dirname)

List all file-type object names that exist at the root of this bucket directory.

Parameters:

dirname (str) – Directory name in the bucket relative to bucket_root/.

Returns:

filenames – List of file names (str), relative to bucket_root/, that exist at the root of dirname.

Return type:

list