本文整理汇总了Python中Orange.widgets.data.owsave.OWSave._extension_from_filter方法的典型用法代码示例。如果您正苦于以下问题:Python OWSave._extension_from_filter方法的具体用法?Python OWSave._extension_from_filter怎么用?Python OWSave._extension_from_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.data.owsave.OWSave
的用法示例。
在下文中一共展示了OWSave._extension_from_filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extension_from_filter
# 需要导入模块: from Orange.widgets.data.owsave import OWSave [as 别名]
# 或者: from Orange.widgets.data.owsave.OWSave import _extension_from_filter [as 别名]
def test_extension_from_filter(self):
self.assertEqual(
OWSave._extension_from_filter("Description (*.ext)"), ".ext")
self.assertEqual(
OWSave._extension_from_filter("Description (*.foo.ba)"), ".foo.ba")
self.assertEqual(
OWSave._extension_from_filter("Description (.ext)"), ".ext")
self.assertEqual(
OWSave._extension_from_filter("Description (.foo.bar)"), ".foo.bar")
示例2: test_save_file_dialog_asks_for_overwrite_darwin
# 需要导入模块: from Orange.widgets.data.owsave import OWSave [as 别名]
# 或者: from Orange.widgets.data.owsave.OWSave import _extension_from_filter [as 别名]
def test_save_file_dialog_asks_for_overwrite_darwin(self, msgbox, dlg):
def selected_files():
nonlocal attempts
attempts += 1
return [["old.tab", "new.tab"][attempts]]
widget = self.widget
widget._initial_start_dir = lambda: "baz"
for filter1 in widget.filters:
if OWSave._extension_from_filter(filter1) == ".tab":
break
widget.filter = filter1
instance = dlg.return_value
instance.exec.return_value = QFileDialog.Accepted
instance.selectedFiles = selected_files
instance.selectedNameFilter.return_value = self.remove_star(filter1)
attempts = -1
msgbox.question.return_value = msgbox.Yes = 1
self.assertEqual(widget.get_save_filename()[0], "old.tab")
attempts = -1
msgbox.question.return_value = msgbox.No = 0
self.assertEqual(widget.get_save_filename()[0], "new.tab")
示例3: test_save_file_dialog_enforces_extension_darwin
# 需要导入模块: from Orange.widgets.data.owsave import OWSave [as 别名]
# 或者: from Orange.widgets.data.owsave.OWSave import _extension_from_filter [as 别名]
def test_save_file_dialog_enforces_extension_darwin(self, dlg):
widget = self.widget
for filter1 in widget.filters:
if OWSave._extension_from_filter(filter1) == ".tab":
break
for filter2 in widget.filters:
if OWSave._extension_from_filter(filter2) == ".csv.gz":
break
widget.filter = filter1
instance = dlg.return_value
instance.exec.return_value = QFileDialog.Accepted
instance.selectedNameFilter.return_value = self.remove_star(filter1)
instance.selectedFiles.return_value = ["foo"]
self.assertEqual(widget.get_save_filename()[0], "foo.tab")
instance.selectedFiles.return_value = ["foo.pkl"]
self.assertEqual(widget.get_save_filename()[0], "foo.tab")
instance.selectedFiles.return_value = ["foo.tab.gz"]
self.assertEqual(widget.get_save_filename()[0], "foo.tab")
instance.selectedFiles.return_value = ["foo.csv.gz"]
self.assertEqual(widget.get_save_filename()[0], "foo.tab")
instance.selectedFiles.return_value = ["foo.bar"]
self.assertEqual(widget.get_save_filename()[0], "foo.bar.tab")
instance.selectedNameFilter.return_value = self.remove_star(filter2)
instance.selectedFiles.return_value = ["foo"]
self.assertEqual(widget.get_save_filename()[0], "foo.csv.gz")
instance.selectedFiles.return_value = ["foo.pkl"]
self.assertEqual(widget.get_save_filename()[0], "foo.csv.gz")
instance.selectedFiles.return_value = ["foo.tab.gz"]
self.assertEqual(widget.get_save_filename()[0], "foo.csv.gz")
instance.selectedFiles.return_value = ["foo.csv.gz"]
self.assertEqual(widget.get_save_filename()[0], "foo.csv.gz")
instance.selectedFiles.return_value = ["foo.bar"]
self.assertEqual(widget.get_save_filename()[0], "foo.bar.csv.gz")