File Utilities
Simple and small module that covers file uploads and checksum calculation as well as string extraction of a file.
- mastf.MASTF.utils.upload.checksum_from_path(file_path: str) tuple [source]
Calculates SHA256, SHA1 and MD5 for the file at the given path.
- Parameters:
file_path (str) – the absolute file path
- Returns:
sha256, sha1 and md5 of the given file
- Return type:
tuple
- mastf.MASTF.utils.upload.get_file_checksum(fp: IOBase) tuple [source]
Efficient way to cumpute sha256, sha1 and md5 checksum
- Parameters:
fp (IOBase) – the file pointer object
- Returns:
sha256, sha1 and md5 of the given file
- Return type:
tuple
- mastf.MASTF.utils.upload.handle_scan_file_upload(file: TemporaryUploadedFile, project: Project)[source]
Handles a generic file upload to the given project.
- Parameters:
file (TemporaryUploadedFile) – the file to be saved
project (Project) – the target project
- Returns:
a
File
object on success,None
otherwise- Return type:
File
|NoneType