From 69e219b6b8d212298731d88861e80ae50dc63d3c Mon Sep 17 00:00:00 2001 From: Theodore Chang <theodore.chang@physik.hu-berlin.de> Date: Fri, 23 Aug 2024 11:23:31 +0000 Subject: [PATCH] Resolve "This found entry in the search does not exist" --- nomad/files.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nomad/files.py b/nomad/files.py index c960c9e9a9..1aad369722 100644 --- a/nomad/files.py +++ b/nomad/files.py @@ -43,6 +43,8 @@ one entry based on the other, etc. In this case the other mainfile is an *aux fi original mainfile, and vice versa. """ +from __future__ import annotations + from abc import ABCMeta from typing import ( IO, @@ -705,13 +707,12 @@ class UploadFiles(DirectoryObject, metaclass=ABCMeta): raise NotImplementedError() @staticmethod - def get(upload_id: str, create: bool = False) -> 'UploadFiles': - if StagingUploadFiles.exists_for(upload_id): - return StagingUploadFiles(upload_id, create) - elif PublicUploadFiles.exists_for(upload_id): - return PublicUploadFiles(upload_id, create) - else: - return None + def get(upload_id: str, create: bool = False) -> UploadFiles | None: + for class_type in (PublicUploadFiles, StagingUploadFiles): + if class_type.exists_for(upload_id): + return class_type(upload_id, create) + + return None def is_empty(self) -> bool: """If this upload has no content yet.""" -- GitLab