Changeset f0a9a3cc in sasview for guiframe


Ignore:
Timestamp:
Jun 8, 2009 2:27:40 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
d4ccbb1
Parents:
ff3f900b
Message:

remove save as xml function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/local_perspectives/plotting/Plotter1D.py

    r4ac8556 rf0a9a3cc  
    420420                
    421421                
    422     def _onSaveXML(self, path): 
    423         """ 
    424             Save 1D  Data to  XML file 
    425              
    426             TODO: Refactor and remove this method. See TODO in _onSave. 
    427              
    428             @param evt: Menu event 
    429         """ 
    430         if not path == None: 
    431             out = open(path, 'w') 
    432             from DataLoader.readers import cansas_reader 
    433             reader = cansas_reader.Reader() 
    434             data= self.plots[self.graph.selected_plottable] 
    435             if hasattr(data, "info"): 
    436                 datainfo= data.info 
    437             else: 
    438                 datainfo= data 
    439             try: 
    440                 reader.write( path, datainfo) 
    441             except: 
    442                 msg= "couldn't save point %s"%sys.exc_value 
    443                 raise  
    444             
    445             try: 
    446                 self._default_save_location = os.path.dirname(path) 
    447             except: 
    448                 pass 
    449          
    450         return  
    451      
    452      
    453422    def _onsaveTXT(self, path): 
    454423        """ 
     
    499468            @param evt: Menu event 
    500469        """ 
    501         import os 
     470        
    502471        id = str(evt.GetId()) 
    503472        if id in self.action_ids:          
     
    515484                #TODO: This is bad design. The DataLoader is designed to recognize extensions. 
    516485                # It should be a simple matter of calling the .save(file, data, '.xml') method 
    517                 # of the DataLoader.loader.Loader class.  
    518                  
    519                 if os.path.splitext(mypath)[1].lower() ==".txt": 
    520                     self._onsaveTXT(path) 
    521                 if os.path.splitext(mypath)[1].lower() ==".xml": 
    522                     self._onSaveXML(path) 
    523              
     486                # of the DataLoader.loader.Loader class. 
     487                from DataLoader.loader import  Loader 
     488                #Instantiate a loader  
     489                loader = Loader()  
     490                data = self.plots[self.graph.selected_plottable] 
     491                format=".txt" 
     492                if os.path.splitext(mypath)[1].lower() == format: 
     493                     self._onsaveTXT( path) 
     494 
     495                format= ".xml" 
     496                if os.path.splitext(mypath)[1].lower() ==format: 
     497                    loader.save( path, data, format) 
     498                try: 
     499                    self._default_save_location = os.path.dirname(path) 
     500                except: 
     501                    pass     
    524502            dlg.Destroy() 
    525503             
     504             
     505     
     506             
    526507            
    527508     
Note: See TracChangeset for help on using the changeset viewer.