gurutracker.storage package

Submodules

gurutracker.storage.base module

class gurutracker.storage.base.Base[source]

Bases: ABC

This class is to be used as a base for all storage backends.

One must implement all the methods declared here, for a fully working File Storage adapter.

abstract get_all(dirpath)[source]

Put all files in a folder, and each file should be named as file_{fileid:04d}

Parameters:

dirpath (str) – The directory to put all the files into.

abstract get_file(assignment)[source]

Get the file which is linked to the assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment whose files are to be got.

Returns:

File object with an attribute .ext - extension of file

Raises:

gurutracker.storage.base.CannotGetFileError – When the file cannot be got.

abstract has_linked_file(assignment)[source]

Check if file is linked to the assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment to check.

Associate a file (binary file object) with an assignment.

Parameters:
Raises:

gurutracker.storage.base.CannotLinkFileError – When the file cannot be created.

Unlink all files related to assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment whose files are to be unlinked.

Raises:

gurutracker.storage.base.CannotUnlinkFileError – When the file cannot be created.

exception gurutracker.storage.base.FileLinkageError(assignment, fp, e)[source]

Bases: StorageError

When a storage adapter cannot link/associate a file, this error to be raised.

exception gurutracker.storage.base.NoLinkedFileError(assignment)[source]

Bases: StorageError

When a storage adapter cannot link/associate a file, this error to be raised.

exception gurutracker.storage.base.StorageError[source]

Bases: Exception

gurutracker.storage.filesystem module

class gurutracker.storage.filesystem.FilesystemDirectory(directory)[source]

Bases: Base

get_all(dirpath)[source]

Put all files in a folder, and each file should be named as file_{fileid:04d}

Parameters:

dirpath (str) – The directory to put all the files into.

get_file(assignment)[source]

Get the file which is linked to the assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment whose files are to be got.

Raises:

gurutracker.storage.base.CannotGetFileError – When the file cannot be got.

has_linked_file(assignment)[source]

Check if file is linked to the assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment to check.

Associate a file (binary file object) with an assignment.

Parameters:
Raises:

gurutracker.storage.base.CannotLinkFileError – When the file cannot be created.

Unlink all files related to assignment.

Parameters:

assignment (gurutracker.database.objects.Assignment) – The assignment whose files are to be unlinked.

Raises:

gurutracker.storage.base.CannotUnlinkFileError – When the file cannot be created.

gurutracker.storage.myphp module

Module contents