当前位置: 首页>>代码示例>>Python>>正文


Python OWSave._extension_from_filter方法代码示例

本文整理汇总了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")
开发者ID:ales-erjavec,项目名称:orange3,代码行数:11,代码来源:test_owsave.py

示例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")
开发者ID:ales-erjavec,项目名称:orange3,代码行数:27,代码来源:test_owsave.py

示例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")
开发者ID:ales-erjavec,项目名称:orange3,代码行数:38,代码来源:test_owsave.py


注:本文中的Orange.widgets.data.owsave.OWSave._extension_from_filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。