Skip to content

Commit 73310de

Browse files
committed
owdataset: Do not capture self in closure
Parameterize and move the functions out of the class.
1 parent c25f185 commit 73310de

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Orange/widgets/data/owdatasets.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def ensure_local(index_url, file_path, local_cache_path,
4444
return localfiles.localpath_download(*file_path, callback=progress_advance)
4545

4646

47+
def list_remote(server: str) -> Dict[Tuple[str, ...], dict]:
48+
client = ServerFiles(server)
49+
return client.allinfo()
50+
51+
52+
def list_local(path: str) -> Dict[Tuple[str, ...], dict]:
53+
return LocalFiles(path).allinfo()
54+
55+
4756
def format_exception(error):
4857
# type: (BaseException) -> str
4958
return "\n".join(traceback.format_exception_only(type(error), error))
@@ -256,7 +265,7 @@ def __init__(self):
256265
self.setStatusMessage("Initializing")
257266

258267
self._executor = ThreadPoolExecutor(max_workers=1)
259-
f = self._executor.submit(self.list_remote)
268+
f = self._executor.submit(list_remote, self.INDEX_URL)
260269
w = FutureWatcher(f, parent=self)
261270
w.done.connect(self.__set_index)
262271

@@ -349,7 +358,7 @@ def __set_index(self, f):
349358
assert f.done()
350359
self.setBlocking(False)
351360
self.setStatusMessage("")
352-
self.allinfo_local = self.list_local()
361+
self.allinfo_local = list_local(self.local_cache_path)
353362

354363
try:
355364
self.allinfo_remote = f.result()
@@ -385,7 +394,7 @@ def __set_index(self, f):
385394

386395
def __update_cached_state(self):
387396
model = self.view.model().sourceModel()
388-
localinfo = self.list_local()
397+
localinfo = list_local(self.local_cache_path)
389398
assert isinstance(model, QStandardItemModel)
390399
allinfo = []
391400
for i in range(model.rowCount()):
@@ -552,15 +561,6 @@ def load_and_output(self, path):
552561
def load_data(path):
553562
return Orange.data.Table(path)
554563

555-
def list_remote(self):
556-
# type: () -> Dict[Tuple[str, ...], dict]
557-
client = ServerFiles(server=self.INDEX_URL)
558-
return client.allinfo()
559-
560-
def list_local(self):
561-
# type: () -> Dict[Tuple[str, ...], dict]
562-
return LocalFiles(self.local_cache_path).allinfo()
563-
564564

565565
class FutureWatcher(QObject):
566566
done = Signal(object)

0 commit comments

Comments
 (0)