Files
notes/02-projects/Uplink/models.py.md
T
2026-07-14 08:05:36 -07:00

2.0 KiB

Classes

BackupTask

@dataclass
class BackupTask:
""" 
Defines a backup task.

This dataclass is used to define a backup task to be handled by the backup engine selected by the user. Defines the source path, destination path and user defined exclude patterns. 

args:
	- source (Path): absolute path of the source directory
	- dest (Path): absolute path of the destination directory
	- exclude_pattern (str): regex pattern to define what files or directories
	  should be excluded from the backup
"""
	source: Path
	dest: Path
	exclude_pattern: str
	
	@cached_property
	def size(self) -> float
	"""
	Calculates total size of all files and sub-directories in source path
	
	returns:
		- float: total size in megabytes
		
	raises:
		- IOError: in any case where an IO error occurs
		- FileNotFoundError: If source is not found or is an invalid path
	"""
	
	def refresh_size(self) -> None:
	"""
	Forces a refresh of the size of the source directory.
	Useful if you think the file size may have change significantly since the
	creation of the object instance
	
	raise:
		- IOError: in any case where an IO error occurs
		- FileNotFoundError: If source is not found or is an invalid path
	
	"""

Args

  • source (Path): absolute path of the source directory
  • dest (Path): absolute path of the destination directory
  • exclude_pattern (str): regex pattern to define what files or directories should be excluded from the backup
size

@cached_property

Calculates total size of all files and sub-directories in source path

returns:

  • float: total size in megabytes

raises:

  • IOError: in any case where an IO error occurs
  • FileNotFoundError: If source is not found or is an invalid path
refresh_size

Forces a refresh of the size of the source directory. Useful if you think the file size may have change significantly since the creation of the object instance

raise:

  • IOError: in any case where an IO error occurs
  • FileNotFoundError: If source is not found or is an invalid path