diff --git a/Orange/widgets/data/owdatasets.py b/Orange/widgets/data/owdatasets.py index af8a55e8571..21c0c1309b0 100644 --- a/Orange/widgets/data/owdatasets.py +++ b/Orange/widgets/data/owdatasets.py @@ -44,6 +44,15 @@ def ensure_local(index_url, file_path, local_cache_path, return localfiles.localpath_download(*file_path, callback=progress_advance) +def list_remote(server: str) -> Dict[Tuple[str, ...], dict]: + client = ServerFiles(server) + return client.allinfo() + + +def list_local(path: str) -> Dict[Tuple[str, ...], dict]: + return LocalFiles(path).allinfo() + + def format_exception(error): # type: (BaseException) -> str return "\n".join(traceback.format_exception_only(type(error), error)) @@ -256,7 +265,7 @@ def __init__(self): self.setStatusMessage("Initializing") self._executor = ThreadPoolExecutor(max_workers=1) - f = self._executor.submit(self.list_remote) + f = self._executor.submit(list_remote, self.INDEX_URL) w = FutureWatcher(f, parent=self) w.done.connect(self.__set_index) @@ -349,7 +358,7 @@ def __set_index(self, f): assert f.done() self.setBlocking(False) self.setStatusMessage("") - self.allinfo_local = self.list_local() + self.allinfo_local = list_local(self.local_cache_path) try: self.allinfo_remote = f.result() @@ -385,7 +394,7 @@ def __set_index(self, f): def __update_cached_state(self): model = self.view.model().sourceModel() - localinfo = self.list_local() + localinfo = list_local(self.local_cache_path) assert isinstance(model, QStandardItemModel) allinfo = [] for i in range(model.rowCount()): @@ -552,15 +561,6 @@ def load_and_output(self, path): def load_data(path): return Orange.data.Table(path) - def list_remote(self): - # type: () -> Dict[Tuple[str, ...], dict] - client = ServerFiles(server=self.INDEX_URL) - return client.allinfo() - - def list_local(self): - # type: () -> Dict[Tuple[str, ...], dict] - return LocalFiles(self.local_cache_path).allinfo() - class FutureWatcher(QObject): done = Signal(object)