Ignore:
Timestamp:
Sep 8, 2008 5:16:37 PM (16 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:
aa92772
Parents:
bee885e
Message:

working on pluging model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/models.py

    r060b857 r1c66bc5  
    44 
    55(ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent() 
    6  
     6def _findModels(dir): 
     7    # List of plugin objects 
     8    plugins = [] 
     9    # Go through files in plug-in directory 
     10    try: 
     11        list = os.listdir(dir) 
     12        for item in list: 
     13            toks = os.path.splitext(os.path.basename(item)) 
     14            if toks[1]=='.py' and not toks[0]=='__init__': 
     15                name = toks[0] 
     16             
     17                path = [os.path.abspath(dir)] 
     18                file = None 
     19                try: 
     20                    (file, path, info) = imp.find_module(name, path) 
     21                    module = imp.load_module( name, file, item, info ) 
     22                    if hasattr(module, "Model"): 
     23                        try: 
     24                            plugins.append(module.Model) 
     25                        except: 
     26                            log("Error accessing Model in %s\n  %s" % (name, sys.exc_value)) 
     27                except: 
     28                    pass 
     29                finally: 
     30                    if not file==None: 
     31                        file.close() 
     32    except: 
     33        pass 
     34    return plugins 
    735 
    836 
Note: See TracChangeset for help on using the changeset viewer.