class documentation

class ScanDirectoryManager: (source)

Constructor: ScanDirectoryManager(base_scan_dir)

View In Hierarchy

A class for managing interactions with scan directories.

Method __init__ Initialise the scan directory manager.
Method all_scans_info Return a lists of ScanInfo objects for each scan.
Method check_free_disk_space Raise an exception if there is not enough free disk space to continue scanning.
Method delete_scan Delete a scan.
Method exists Return True if scan of this name exists on disk.
Method get_file_path_from Return the full file path for the file within a scan directory.
Method get_file_path_from_img_dir Return the full file path for the file within a scan directory.
Method get_final_stitch_path Return the file full path for the final stitch.
Method get_scan_data_dict Return the scan data read from a JSON file as a dict.
Method get_scan_data_path Return the file full path scan data JSON file.
Method img_dir_for Return the path for the image dir for a given scan name.
Method new_scan_dir Get a unique name for this scan and create a directory for it.
Method path_for Return the path for a given scan name.
Method zip_scan Zips any images from the scan not yet zipped, return full path to zip.
Property all_scans Return a list of the scan names in the base directory.
Property base_dir The base directory scans are saved to.
Method _unique_scan_name Get the next unique scan name starting with the given name.
Instance Variable _base_scan_dir Undocumented
Instance Variable _lock Undocumented
def __init__(self, base_scan_dir: str): (source)

Initialise the scan directory manager.

Parameters
base_scan_dir:strPath of the directory that holds all scans.
def all_scans_info(self) -> list[ScanInfo]: (source)

Return a lists of ScanInfo objects for each scan.

def check_free_disk_space(self, min_space: int = 500000000): (source)

Raise an exception if there is not enough free disk space to continue scanning.

Parameters
min_space:intthe minimum space required in bytes. Default = 500,000,000 (500MB)
Raises
NotEnoughFreeSpaceErrorif the remaining storage is below min_space
def delete_scan(self, scan_name: str): (source)

Delete a scan.

def exists(self, scan_name: str) -> bool: (source)

Return True if scan of this name exists on disk.

def get_file_path_from(self, scan_name: str, filename: str, check_exists: bool = False) -> str | None: (source)

Return the full file path for the file within a scan directory.

If check_exists is True then None will be returned if the file does not exist.

def get_file_path_from_img_dir(self, scan_name: str, filename: str, check_exists: bool = False) -> str | None: (source)

Return the full file path for the file within a scan directory.

If check_exists is True, None is returned if the file does not exist. If False then the path is returned anyway

def get_final_stitch_path(self, scan_name: str) -> str | None: (source)

Return the file full path for the final stitch.

If no final stitch is found, return None

def get_scan_data_dict(self, scan_name: str) -> dict[str, Any] | None: (source)

Return the scan data read from a JSON file as a dict.

This is a dictionary not a base model as the data format has changed somewhat over time.

def get_scan_data_path(self, scan_name: str) -> str | None: (source)

Return the file full path scan data JSON file.

If no scan data JSON file is found, return None

def img_dir_for(self, scan_name: str) -> str: (source)

Return the path for the image dir for a given scan name.

Returns the path even if it doesn't exist

def new_scan_dir(self, scan_name: str) -> ScanDirectory: (source)

Get a unique name for this scan and create a directory for it.

The scan will be named {scan_name}_0001 where the number is zero-padded to be SCAN_ZERO_PAD_DIGITS digits long (to allow correct sorting if the scans are ordered alphanumerically).

Creates a new empty folder, into which scans are saved

Returns the a ScanDirectory object

def path_for(self, scan_name: str) -> str: (source)

Return the path for a given scan name.

Returns the path even if it doesn't exist

def zip_scan(self, scan_name: str, final_version: bool = False) -> ScanDirectory: (source)

Zips any images from the scan not yet zipped, return full path to zip.

final_version Set true to stitch all files not just the scan images this should only be done at the end as it is not possible to update a file in a zip.

@property
@requires_lock
all_scans: list[str] = (source)

Return a list of the scan names in the base directory.

@property
base_dir: str = (source)

The base directory scans are saved to.

def _unique_scan_name(self, scan_name: str) -> str: (source)

Get the next unique scan name starting with the given name.

For more explanation on the scan naming see new_scan_dir

_base_scan_dir: str = (source)

Undocumented

Undocumented