Skip to content

Commit

Permalink
Merge pull request biolab#2781 from lanzagar/datasets
Browse files Browse the repository at this point in the history
owdatasets: Further generalizations of the widget
  • Loading branch information
markotoplak authored Nov 30, 2017
2 parents 97e0e82 + da20035 commit f1a4be1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Orange/widgets/data/owdatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
log = logging.getLogger(__name__)


def ensure_local(index_url, domain, filename, local_cache_path,
def ensure_local(index_url, file_path, local_cache_path,
force=False, progress_advance=None):
localfiles = LocalFiles(local_cache_path,
serverfiles=ServerFiles(server=index_url))
if force:
localfiles.download(domain, filename, callback=progress_advance)
return localfiles.localpath_download(
domain, filename, callback=progress_advance)
localfiles.download(*file_path, callback=progress_advance)
return localfiles.localpath_download(*file_path, callback=progress_advance)


def format_info(n_all, n_cached):
Expand Down Expand Up @@ -228,7 +227,7 @@ def __set_index(self, f):
self.Warning.only_local_datasets()
res = {}

allinforemote = res # type: Dict[Tuple[str, str], dict]
allinforemote = res # type: Dict[Tuple[str, ...], dict]
allkeys = set(allinfolocal)
if allinforemote is not None:
allkeys = allkeys | set(allinforemote)
Expand All @@ -249,6 +248,7 @@ def info(file_path):
filename = file_path[-1]

return namespace(
file_path=file_path,
prefix=prefix, filename=filename,
title=info.get("title", filename),
datetime=info.get("datetime", None),
Expand Down Expand Up @@ -322,7 +322,7 @@ def __update_cached_state(self):
for i in range(model.rowCount()):
item = model.item(i, 0)
info = item.data(Qt.UserRole)
info.islocal = (info.prefix, info.filename) in localinfo
info.islocal = info.file_path in localinfo
item.setData(" " if info.islocal else "", Qt.DisplayRole)
allinfo.append(info)

Expand Down Expand Up @@ -405,7 +405,7 @@ def commit(self):
self.setBlocking(True)

f = self._executor.submit(
ensure_local, self.INDEX_URL, di.prefix, di.filename,
ensure_local, self.INDEX_URL, di.file_path,
self.local_cache_path, force=di.outdated,
progress_advance=callback)
w = FutureWatcher(f, parent=self)
Expand All @@ -414,7 +414,7 @@ def commit(self):
else:
self.setStatusMessage("")
self.setBlocking(False)
self.commit_cached(di.prefix, di.filename)
self.commit_cached(di.file_path)
else:
self.Outputs.data.send(None)

Expand Down Expand Up @@ -448,8 +448,8 @@ def __commit_complete(self, f):
data = None
self.Outputs.data.send(data)

def commit_cached(self, prefix, filename):
path = LocalFiles(self.local_cache_path).localpath(prefix, filename)
def commit_cached(self, file_path):
path = LocalFiles(self.local_cache_path).localpath(*file_path)
self.Outputs.data.send(Orange.data.Table(path))

@Slot()
Expand All @@ -473,12 +473,12 @@ def closeEvent(self, event):
super().closeEvent(event)

def list_remote(self):
# type: () -> Dict[Tuple[str, str], dict]
# type: () -> Dict[Tuple[str, ...], dict]
client = ServerFiles(server=self.INDEX_URL)
return client.allinfo()

def list_local(self):
# type: () -> Dict[Tuple[str, str], dict]
# type: () -> Dict[Tuple[str, ...], dict]
return LocalFiles(self.local_cache_path).allinfo()


Expand Down

0 comments on commit f1a4be1

Please sign in to comment.