本文整理汇总了Python中Orange.widgets.data.owsave.OWSave类的典型用法代码示例。如果您正苦于以下问题:Python OWSave类的具体用法?Python OWSave怎么用?Python OWSave使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OWSave类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_graph
def save_graph(self):
from Orange.widgets.data.owsave import OWSave
save_img = OWSave(data={'scene': self.scene, 'tree': self.tree},
file_formats=dict(chain(
FileFormat.img_writers.items(),
FileFormat.graph_writers.items())))
save_img.exec_()
示例2: test_extension_from_filter
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")
示例3: test_save_file_dialog_asks_for_overwrite_darwin
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")
示例4: test_filename_with_fix_extension
def test_filename_with_fix_extension(self):
def mock_fix_choice(ret):
f = lambda *x: ret
f.__dict__.update(fix_extension.__dict__)
return f
change_filter = iter([PickleReader, TabReader])
for file_choice, fix in [
[lambda *x: ("o.pickle", format_filter(TabReader)),
mock_fix_choice(fix_extension.CHANGE_EXT)],
[lambda *x: ("o.tab", format_filter(PickleReader)),
mock_fix_choice(fix_extension.CHANGE_FORMAT)],
[lambda *x: ("o.tab", format_filter(next(change_filter))),
mock_fix_choice(fix_extension.CANCEL)]
]:
with patch("AnyQt.QtWidgets.QFileDialog.getSaveFileName", file_choice),\
patch("Orange.widgets.utils.filedialogs.fix_extension", fix):
saved_filename, format, filter = \
open_filename_dialog_save(".", None, OWSave.get_writers(False))
self.assertEqual(saved_filename, "o.tab")
self.assertEqual(format, TabReader)
self.assertEqual(filter, format_filter(TabReader))
示例5: test_save_file_dialog_enforces_extension_darwin
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")
示例6: save_graph
def save_graph(self):
from Orange.widgets.data.owsave import OWSave
save_img = OWSave(data=self.grid_widget,
file_formats=FileFormat.img_writers)
save_img.exec_()
示例7: test_migration_to_version_2
def test_migration_to_version_2(self):
const_settings = {
'add_type_annotations': True, 'auto_save': False,
'controlAreaVisible': True, 'last_dir': '/home/joe/Desktop',
'__version__': 1}
# No compression, Tab-separated values
settings = {**const_settings,
'compress': False, 'compression': 'gzip (.gz)',
'filetype': 'Tab-separated values (.tab)'}
OWSave.migrate_settings(settings)
self.assertEqual(
settings,
{**const_settings,
"filter": "Tab-separated values (*.tab)"})
# Compression; ignore compression format (.xz is no longer supported)
settings = {**const_settings,
'compress': True, 'compression': 'lzma (.xz)',
'filetype': 'Tab-separated values (.tab)'}
OWSave.migrate_settings(settings)
self.assertEqual(
settings,
{**const_settings,
"filter": "Compressed Tab-separated values (*.tab.gz)"})
# No compression, Excel
settings = {**const_settings,
'compress': False, 'compression': 'lzma (.xz)',
'filetype': 'Microsoft Excel spreadsheet (.xlsx)'}
OWSave.migrate_settings(settings)
self.assertEqual(
settings,
{**const_settings,
"filter": "Microsoft Excel spreadsheet (*.xlsx)"})
# Excel with compression - compression must be ignored
settings = {**const_settings,
'compress': True, 'compression': 'lzma (.xz)',
'filetype': 'Microsoft Excel spreadsheet (.xlsx)'}
OWSave.migrate_settings(settings)
self.assertEqual(
settings,
{**const_settings,
"filter": "Microsoft Excel spreadsheet (*.xlsx)"})
# Missing filetype (is this possible?)
settings = {**const_settings,
'compress': True, 'compression': 'lzma (.xz)'}
OWSave.migrate_settings(settings)
self.assertTrue(settings["filter"] in OWSave.filters)
# Unsupported file format (is this possible?)
settings = {**const_settings,
'compress': True, 'compression': 'lzma (.xz)',
'filetype': 'Bar file (.bar)'}
OWSave.migrate_settings(settings)
self.assertTrue(settings["filter"] in OWSave.filters)