Beispiel #1
0
def proto_progress_to_native(progress: pb.Progress) -> Progress:
    kind = progress.WhichOneof("value")
    if kind == "media_sync":
        return Progress(kind=ProgressKind.MediaSync, val=progress.media_sync)
    elif kind == "media_check":
        return Progress(kind=ProgressKind.MediaCheck, val=progress.media_check)
    else:
        assert_impossible_literal(kind)
Beispiel #2
0
 def from_proto(proto: pb.Progress) -> Progress:
     kind = proto.WhichOneof("value")
     if kind == "media_sync":
         return Progress(kind=ProgressKind.MediaSync, val=proto.media_sync)
     elif kind == "media_check":
         return Progress(kind=ProgressKind.MediaCheck, val=proto.media_check)
     elif kind == "full_sync":
         return Progress(kind=ProgressKind.FullSync, val=proto.full_sync)
     elif kind == "normal_sync":
         return Progress(kind=ProgressKind.NormalSync, val=proto.normal_sync)
     else:
         return Progress(kind=ProgressKind.NoProgress, val="")