Changeset 4657:aa97cf1a8bd1 in orange


Ignore:
Timestamp:
05/17/08 23:57:33 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
c5020fb2c9439f7debc479f28c6d1ec9683eb94f
Message:
  • offers file formats from orngIO, too (in particular, arff and R)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Data/OWSave.py

    r4440 r4657  
    1515from OWWidget import * 
    1616import OWGUI 
    17 import re, os.path, user, sys 
     17import os.path, user, sys 
    1818from exceptions import Exception 
    1919 
     
    2121    settingsList=["recentFiles","selectedFileName"] 
    2222 
     23    savers = {".txt": orange.saveTxt, ".tab": orange.saveTabDelimited, 
     24              ".names": orange.saveC45, ".test": orange.saveC45, ".data": orange.saveC45, 
     25              ".csv": orange.saveCsv 
     26              } 
     27 
     28    # exclude C50 since it has the same extension and we do not need saving to it anyway 
     29    registeredFileTypes = [ft for ft in orange.getRegisteredFileTypes() if len(ft)>3 and ft[3] and not ft[0]=="C50"] 
     30     
     31    dlgFormats = 'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nRetis files (*.rda *.rdo)\n' \ 
     32                 + "\n".join("%s (%s)" % (ft[:2]) for ft in registeredFileTypes) \ 
     33                 + "\nAll files(*.*)" 
     34 
     35    savers.update(dict((lower(ft[1][1:]), ft[3]) for ft in registeredFileTypes)) 
     36     
    2337    def __init__(self,parent=None, signalManager = None): 
    2438        OWWidget.__init__(self, parent, signalManager, "Save") 
     
    5165         
    5266 
    53     savers = {".txt": orange.saveTxt, ".tab": orange.saveTabDelimited, 
    54               ".names": orange.saveC45, ".test": orange.saveC45, ".data": orange.saveC45, 
    55               ".csv": orange.saveCsv 
    56               } 
    57      
    58     re_filterExtension = re.compile(r"\(\*(?P<ext>\.[^ )]+)") 
    59  
    6067    def dataset(self, data): 
    6168        self.data = data 
     
    6875            startfile = user.home 
    6976 
    70         dlg = QFileDialog.getSaveFileName(startfile, 
    71                           'Tab-delimited files (*.tab)\nHeaderless tab-delimited (*.txt)\nComma separated (*.csv)\nC4.5 files (*.data)\nRetis files (*.rda *.rdo)\nAll files(*.*)', #\nAssistant files (*.dat) 
    72                           None, "Orange Data File") 
     77        dlg = QFileDialog.getSaveFileName(startfile, self.dlgFormats, None, "Orange Data File") 
    7378#        dlg.exec_loop() 
    7479 
     
    7883         
    7984        ext = lower(os.path.splitext(filename)[1]) 
    80         if not self.savers.has_key(ext): 
     85        if not ext in self.savers: 
    8186            filt_ext = ".tab" 
    8287            filename += filt_ext 
Note: See TracChangeset for help on using the changeset viewer.