def _stored_object_to_fetch_result( ctx: contextlib.ExitStack, stored_object: Optional[StoredObject], wf_module_fetch_error: str, dir: Path, ) -> Optional[FetchResult]: """ Given a StoredObject (or None), return a FetchResult (or None). This cannot error. Any errors lead to a `None` return value. """ if stored_object is None: return None else: try: last_fetch_path = ctx.enter_context( storedobjects.downloaded_file(stored_object, dir=dir)) if wf_module_fetch_error: errors = [ RenderError(I18nMessage.TODO_i18n(wf_module_fetch_error)) ] else: errors = [] return FetchResult(last_fetch_path, errors) except FileNotFoundError: return None
def _stored_object_to_fetch_result( exit_stack: contextlib.ExitStack, stored_object: Optional[StoredObject], step_fetch_errors: List[FetchError], dir: Path, ) -> Optional[FetchResult]: """Given a StoredObject (or None), return a FetchResult (or None). This cannot error. Any errors lead to a `None` return value. """ if stored_object is None: return None else: try: last_fetch_path = exit_stack.enter_context( storedobjects.downloaded_file(stored_object, dir=dir)) return FetchResult(last_fetch_path, step_fetch_errors) except FileNotFoundError: return None