Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/GuiUtils.py

    r10786bc2 r4333edf  
    1212import urllib.parse 
    1313import json 
     14import types 
    1415from io import BytesIO 
    1516 
     
    4445 
    4546from sas.sascalc.dataloader.loader import Loader 
     47from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
     48 
    4649from sas.qtgui.Utilities import CustomDir 
    4750 
     
    793796 
    794797    wildcard = "Text files (*.txt);;"\ 
    795                 "CanSAS 1D files(*.xml)" 
     798                "CanSAS 1D files(*.xml);;"\ 
     799                "NXcanSAS files (*.h5)" 
    796800    kwargs = { 
    797801        'caption'   : 'Save As', 
     
    812816    if os.path.splitext(filename)[1].lower() == ".txt": 
    813817        onTXTSave(data, filename) 
    814     if os.path.splitext(filename)[1].lower() == ".xml": 
     818    elif os.path.splitext(filename)[1].lower() == ".xml": 
    815819        loader.save(filename, data, ".xml") 
     820    elif os.path.splitext(filename)[1].lower() == ".h5": 
     821        nxcansaswriter = NXcanSASWriter() 
     822        nxcansaswriter.write([data], filename) 
    816823 
    817824def saveData2D(data): 
     
    824831    default_name += "_out" + ext_format 
    825832 
    826     wildcard = "IGOR/DAT 2D file in Q_map (*.dat)" 
     833    wildcard = "IGOR/DAT 2D file in Q_map (*.dat);;"\ 
     834                "NXcanSAS files (*.h5)" 
    827835    kwargs = { 
    828836        'caption'   : 'Save As', 
     
    844852    if os.path.splitext(filename)[1].lower() == ext_format: 
    845853        loader.save(filename, data, ext_format) 
     854    elif os.path.splitext(filename)[1].lower() == ".h5": 
     855        nxcansaswriter = NXcanSASWriter() 
     856        nxcansaswriter.write([data], filename) 
     857 
    846858 
    847859class FormulaValidator(QtGui.QValidator): 
     
    12111223            return add_type(content, type(o)) 
    12121224 
     1225        if isinstance(o, types.FunctionType): 
     1226            # we have a pure function 
     1227            content = o.__dict__.copy() 
     1228            return add_type(content, type(o)) 
     1229 
    12131230        # not supported 
    12141231        logging.info("data cannot be serialized to json: %s" % type(o)) 
     
    12231240    ''' 
    12241241    supported = [ 
    1225         tuple, set, 
     1242        tuple, set, types.FunctionType, 
    12261243        Sample, Source, Vector, 
    12271244        Plottable, Data1D, Data2D, PlottableTheory1D, PlottableFit1D, Text, Chisq, View, 
     
    12781295            buffer.seek(0) 
    12791296            return np.load(buffer) 
     1297 
     1298        # function 
     1299        if cls == types.FunctionType: 
     1300            return cls 
    12801301 
    12811302        logging.info('not implemented: %s, %s' % (type, cls)) 
Note: See TracChangeset for help on using the changeset viewer.