Exemple #1
0
 def from_storage(
         cls,
         *,
         body: bodies.Body,
         storage: progress.ProgressStorage,
         handlers: Collection[handlers_.BaseHandler],
 ) -> "State":
     handler_states: Dict[handlers_.HandlerId, HandlerState] = {}
     for handler in handlers:
         content = storage.fetch(key=handler.id, body=body)
         handler_states[handler.id] = (HandlerState.from_storage(content) if content else
                                       HandlerState.from_scratch())
     return cls(handler_states)
Exemple #2
0
 def from_storage(
         cls,
         *,
         body: bodies.Body,
         storage: progress.ProgressStorage,
         handlers: Iterable[handlers_.BaseHandler],
 ) -> "State":
     handler_ids = {handler.id for handler in handlers}
     handler_states: Dict[ids.HandlerId, HandlerState] = {}
     for handler_id in handler_ids:
         content = storage.fetch(key=handler_id, body=body)
         if content is not None:
             handler_states[handler_id] = HandlerState.from_storage(content)
     return cls(handler_states)