Skip to content

Commit 6c203a2

Browse files
committed
owfile: support readers with repeated extensions
1 parent 24b836e commit 6c203a2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Orange/widgets/data/owfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def browse_file(self, in_demos=False):
268268
else:
269269
start_file = self.last_path() or os.path.expanduser("~/")
270270

271-
filename, reader, _ = get_file_name_open(start_file, None, FileFormat.readers)
271+
readers = [f for f in FileFormat.formats
272+
if getattr(f, 'read', None) and getattr(f, "EXTENSIONS", None)]
273+
filename, reader, _ = get_file_name_open(start_file, None, readers)
272274
if not filename:
273275
return
274276
self.add_path(filename)

Orange/widgets/utils/filedialogs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def get_file_name_open(start_dir, start_filter, file_formats, title="Open...",
112112
Args:
113113
start_dir (str): initial directory, optionally including the filename
114114
start_filter (str): initial filter
115-
file_formats (dict {extension: Orange.data.io.FileFormat}): file formats
115+
file_formats (a list of Orange.data.io.FileFormat): file formats
116116
title (str): title of the dialog
117117
dialog: a function that creates a QT dialog
118118
Returns:
119119
(filename, filter, file_format), or `(None, None, None)` on cancel
120120
"""
121-
file_formats = sorted(set(file_formats.values()), key=lambda w: w.PRIORITY)
121+
file_formats = sorted(set(file_formats), key=lambda w: (w.PRIORITY, w.DESCRIPTION))
122122
filters = [format_filter(f) for f in file_formats]
123123

124124
# add all readable files option

0 commit comments

Comments
 (0)