genvid.toolbox.SyncFolder

class genvid.toolbox.SyncFolder

Bases: object

DIGEST_ALGORITHM = 'sha512'

The digest algorithm to use.

New in version 1.46.0.

is_thread_safe = False

If the object is thread safe

New in version 1.46.0.

file_checksum(fobject) str
__init__(*, cache: Optional[SyncFolderType] = None, manifest_name: str = 'genvid.manifest', logger: Optional[Logger] = None, uncheck: bool = False)

This abstract class establishes a strategy to sync two folders using their Manifest and, optionally, a local cache.

Parameters:
  • cache – An optional SyncFolder that can be used as an alternative source from added files.

  • manifest_name – Where to find the manifest in the folder.

  • logger – An optional parent logger. The root logger will be used if an optional logger isn’t specified.

  • uncheck – If true, do not use the saved manifest. Depending on the implementation, could generate a new one or just not using it.

New in version 1.42.0.

Changed in version 1.46.0: Add the uncheck parameter.

manifest_name

The name of the manifest in this folder.

logger

The logger used by this instance.

cache

A cache folder for patching.

uncheck

If True, ignored the folder’s manifest.

New in version 1.46.0.

property manifest: Manifest
load() Manifest

Load the manifest if it exists.

Returns:

The folder manifest, or an empty manifest if there is no manifest.

Changed in version 1.46.0: Use generate() if uncheck is True.

generate() Manifest

Create a manifest from the content of the folder.

Returns:

The manifest generated from the content of the folder.

update(*, source: Optional[Manifest] = None, mode: SyncComparisonMode = SyncComparisonMode.Safe, max_workers: Optional[int] = None, progress_bar: bool = True) Manifest

Update the manifest

save(manifest: Manifest)

Save the manifest under this folder.

Parameters:

manifest – The manifest to save.

validate(mode: SyncComparisonMode = SyncComparisonMode.Strict, *, max_workers: Optional[int] = None, progress_bar: bool = True) Iterable[tuple[genvid.toolbox.sync.Manifest.Op, genvid.toolbox.sync.FileStats]]

Validate if the content of the folder corresponds to its manifest. :param mode: The comparison mode for computing the difference. :returns: A list of operations between the folder manifest and its content.

patch_from(origin: SyncFolderType, *, dryrun: bool = False, progress_bar: bool = False, sync_period: float = 60, max_workers: Optional[int] = None, sorted: bool = False)

Patch this folder to be identical to the origin.

Parameters:
  • origin – The folder to sync with.

  • dryrun – Don’t change the folder, only show the operations.

  • progress_bar – Display a progress bar.

  • sync_period – Period after which the manifest is synced. The manifest is only synced after a transfer has been applied successfully.

  • max_workers – The maximum workers to create. If 1 or 0, disable multithreading. The default value of None means using 5 times the number of CPU available.

  • sorted – Sorted the patch by size of transfer, the biggest files first.

Raises:

NotImplementedError – If the folder or origin are incompatible.

class sync.SyncFolder

Implementation of genvid.toolbox.SyncFolder

class sync.SyncFolderType

A TypeVar for genvid.toolbox.SyncFolder