FileReference class

FileReference objects are used to bundle together the file path, size and download token of a specific file. They are typically automatically created and placed in a FileReferenceList by methods of classes inheriting from GWDCObjectBase.

class gwdc_python.files.file_reference.FileReference(path: str, file_size: int, download_token: str, parent: gwdc_python.objects.base.GWDCObjectBase)

Bases: object

Object used to facilitate simpler downloading of files.

download_token: str
file_size: int
parent: gwdc_python.objects.base.GWDCObjectBase
path: str

FileReferenceList class

FileReferenceList objects bundle together many FileReference objects, allowing simpler downloading and filtering of multiple files. As with FileReference objects, FileReferenceList objects are normally created by other methods.

class gwdc_python.files.file_reference.FileReferenceList(data=[])

Bases: gwdc_python.utils.typed_list.TypedList

property batched
filter_list(file_filter_fn, *args, **kwargs)

Create a subset of this list by filtering the contents with a function.

Parameters

file_filter_fn (function) – Must take a list of FileReference objects and return only those that are desired

Returns

Filtered list

Return type

FileReferenceList

filter_list_by_path(directory=None, name=None, extension=None)

Create a subset of this list by filtering the contents based on their path attributes

Parameters
  • directory (str, optional) – Matches any of the directories in the file path, by default None

  • name (str, optional) – Matches the name of the file, by default None

  • extension (str, optional) – Matches the file extension, by default None

Returns

Filtered list

Return type

FileReferenceList

get_parent_type()

Get the storage type for each parent in a list

Returns

List of GWDCObjectType for each parent of the files in the list

Return type

list

get_paths()

Get all the file paths in a list

Returns

List of file paths

Return type

list

get_tokens()

Get all the download tokens in a list

Returns

List of download tokens

Return type

list

get_total_bytes()

Sum the total size of each file represented in the list

Returns

Total size of all files

Return type

int