@@ -455,29 +455,45 @@ def str(self, indent: int = 0) -> str:
455455 # Synchronization between DiffSync instances
456456 # ------------------------------------------------------------------------------
457457
458- def sync_from (self , source : "DiffSync" , diff_class : Type [Diff ] = Diff , flags : DiffSyncFlags = DiffSyncFlags .NONE ):
458+ def sync_from (
459+ self ,
460+ source : "DiffSync" ,
461+ diff_class : Type [Diff ] = Diff ,
462+ flags : DiffSyncFlags = DiffSyncFlags .NONE ,
463+ callback : Optional [Callable [[int , int ], None ]] = None ,
464+ ):
459465 """Synchronize data from the given source DiffSync object into the current DiffSync object.
460466
461467 Args:
462468 source (DiffSync): object to sync data from into this one
463469 diff_class (class): Diff or subclass thereof to use to calculate the diffs to use for synchronization
464470 flags (DiffSyncFlags): Flags influencing the behavior of this sync.
471+ callback (function): Function with parameters (current, total), to be called at intervals as the
472+ calculation of the diff proceeds.
465473 """
466474 diff = self .diff_from (source , diff_class = diff_class , flags = flags )
467- syncer = DiffSyncSyncer (diff = diff , src_diffsync = source , dst_diffsync = self , flags = flags )
475+ syncer = DiffSyncSyncer (diff = diff , src_diffsync = source , dst_diffsync = self , flags = flags , callback = callback )
468476 result = syncer .perform_sync ()
469477 if result :
470478 self .sync_complete (source , diff , flags , syncer .base_logger )
471479
472- def sync_to (self , target : "DiffSync" , diff_class : Type [Diff ] = Diff , flags : DiffSyncFlags = DiffSyncFlags .NONE ):
480+ def sync_to (
481+ self ,
482+ target : "DiffSync" ,
483+ diff_class : Type [Diff ] = Diff ,
484+ flags : DiffSyncFlags = DiffSyncFlags .NONE ,
485+ callback : Optional [Callable [[int , int ], None ]] = None ,
486+ ):
473487 """Synchronize data from the current DiffSync object into the given target DiffSync object.
474488
475489 Args:
476490 target (DiffSync): object to sync data into from this one.
477491 diff_class (class): Diff or subclass thereof to use to calculate the diffs to use for synchronization
478492 flags (DiffSyncFlags): Flags influencing the behavior of this sync.
493+ callback (function): Function with parameters (current, total), to be called at intervals as the
494+ calculation of the diff proceeds.
479495 """
480- target .sync_from (self , diff_class = diff_class , flags = flags )
496+ target .sync_from (self , diff_class = diff_class , flags = flags , callback = callback )
481497
482498 def sync_complete (
483499 self ,
0 commit comments