Changeset b9dbd6b in sasview


Ignore:
Timestamp:
Mar 5, 2015 11:51:04 AM (9 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
824e488
Parents:
3477478
Message:

pylint fixes and remove old code

Location:
src/sas/guiframe/local_perspectives
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/local_perspectives/data_loader/data_loader.py

    r8729965 rb9dbd6b  
    99 
    1010from sas.dataloader.loader import Loader 
    11 import sas.dataloader.data_info as DataInfo 
    1211from sas.guiframe.plugin_base import PluginBase 
    1312from sas.guiframe.events import StatusEvent 
    14 from sas.guiframe.events import NewPlotEvent 
    15 from sas.guiframe.dataFitting import Data1D 
    16 from sas.guiframe.dataFitting import Data2D 
    17 from sas.guiframe.utils import parse_name 
    1813from sas.guiframe.gui_style import GUIFRAME 
    1914from sas.guiframe.gui_manager import DEFAULT_OPEN_FOLDER 
     
    2520        (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): 
    2621        fObj, path, descr = imp.find_module('local_config', [path]) 
    27         config = imp.load_module('local_config', fObj, path, descr)   
     22        config = imp.load_module('local_config', fObj, path, descr) 
    2823    else: 
    2924        # Try simply importing local_config 
    3025        import local_config as config 
    3126except: 
    32     # Didn't find local config, load the default  
     27    # Didn't find local config, load the default 
    3328    import sas.guiframe.config as config 
    3429 
    3530if config is None: 
    3631    import sas.guiframe.config as config 
    37      
    38         
     32 
     33 
    3934extension_list = [] 
    4035if config.APPLICATION_STATE_EXTENSION is not None: 
    4136    extension_list.append(config.APPLICATION_STATE_EXTENSION) 
    42 EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list    
     37EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list 
    4338PLUGINS_WLIST = config.PLUGINS_WLIST 
    4439APPLICATION_WLIST = config.APPLICATION_WLIST 
    4540 
    4641class Plugin(PluginBase): 
    47      
     42 
    4843    def __init__(self, standalone=False): 
    4944        PluginBase.__init__(self, name="DataLoader", standalone=standalone) 
    50         #Default location 
     45        # Default location 
    5146        self._default_save_location = DEFAULT_OPEN_FOLDER 
    52         self.loader = Loader()   
    53         self._data_menu = None  
    54          
    55     def help(self, evt): 
    56         """ 
    57         Show a general help dialog.  
    58         """ 
    59 #        from documentation_window import DocumentationWindow      
    60 #        _sphinx_doc_viewer = DocumentationWindow(self, -1, "/user/guiframe/ \ 
    61 #            data_explorer_help.html", "DataLoader Help") 
    62 #        from help_panel import  HelpWindow 
    63 #        frame = HelpWindow(None, -1)  
    64 #        if hasattr(frame, "IsIconized"): 
    65 #            if not frame.IsIconized(): 
    66 #                try: 
    67 #                    icon = self.parent.GetIcon() 
    68 #                    frame.SetIcon(icon) 
    69 #                except: 
    70 #                    pass   
    71 #        frame.Show(True) 
    72          
     47        self.loader = Loader() 
     48        self._data_menu = None 
     49 
    7350    def populate_file_menu(self): 
    7451        """ 
     
    7653        add load file menu item and load folder item 
    7754        """ 
    78         #menu for data files 
     55        # menu for data files 
    7956        menu_list = [] 
    8057        data_file_hint = "load one or more data in the application" 
     
    8461        style1 = gui_style & GUIFRAME.DATALOADER_ON 
    8562        if style == GUIFRAME.MULTIPLE_APPLICATIONS: 
    86             #menu for data from folder 
     63            # menu for data from folder 
    8764            data_folder_hint = "load multiple data in the application" 
    88             menu_list.append(('&Load Data Folder', data_folder_hint,  
     65            menu_list.append(('&Load Data Folder', data_folder_hint, 
    8966                              self._load_folder)) 
    9067        return menu_list 
    91     
    9268 
    9369    def load_data(self, event): 
     
    9975        if self._default_save_location == None: 
    10076            self._default_save_location = os.getcwd() 
    101          
     77 
    10278        cards = self.loader.get_wildcards() 
    10379        temp = [APPLICATION_WLIST] + PLUGINS_WLIST 
     
    10581            if item in cards: 
    10682                cards.remove(item) 
    107         wlist =  '|'.join(cards) 
    108         style = wx.OPEN|wx.FD_MULTIPLE 
    109         dlg = wx.FileDialog(self.parent,  
    110                             "Choose a file",  
     83        wlist = '|'.join(cards) 
     84        style = wx.OPEN | wx.FD_MULTIPLE 
     85        dlg = wx.FileDialog(self.parent, 
     86                            "Choose a file", 
    11187                            self._default_save_location, "", 
    112                              wlist, 
    113                              style=style) 
     88                            wlist, 
     89                            style=style) 
    11490        if dlg.ShowModal() == wx.ID_OK: 
    11591            file_list = dlg.GetPaths() 
    116             if len(file_list) >= 0 and not(file_list[0]is None): 
     92            if len(file_list) >= 0 and not file_list[0] is None: 
    11793                self._default_save_location = os.path.dirname(file_list[0]) 
    11894                path = self._default_save_location 
    11995        dlg.Destroy() 
    120          
     96 
    12197        if path is None or not file_list or file_list[0] is None: 
    12298            return 
    12399        self.parent._default_save_location = self._default_save_location 
    124100        self.get_data(file_list) 
    125          
    126          
     101 
     102 
    127103    def can_load_data(self): 
    128104        """ 
     
    130106        """ 
    131107        return True 
    132   
    133         
     108 
     109 
    134110    def _load_folder(self, event): 
    135111        """ 
     
    140116        if self._default_save_location == None: 
    141117            self._default_save_location = os.getcwd() 
    142         dlg = wx.DirDialog(self.parent, "Choose a directory",  
     118        dlg = wx.DirDialog(self.parent, "Choose a directory", 
    143119                           self._default_save_location, 
    144                             style=wx.DD_DEFAULT_STYLE) 
     120                           style=wx.DD_DEFAULT_STYLE) 
    145121        if dlg.ShowModal() == wx.ID_OK: 
    146122            path = dlg.GetPath() 
     
    150126            self._default_save_location = os.path.dirname(path) 
    151127        else: 
    152             return     
     128            return 
    153129        file_list = self.get_file_path(path) 
    154130        self.get_data(file_list) 
    155131        self.parent._default_save_location = self._default_save_location 
    156          
     132 
    157133    def load_error(self, error=None): 
    158134        """ 
    159135        Pop up an error message. 
    160          
     136 
    161137        :param error: details error message to be displayed 
    162138        """ 
    163139        if error is not None or str(error).strip() != "": 
    164140            dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 
    165                                 wx.OK | wx.ICON_EXCLAMATION) 
    166             dial.ShowModal()   
    167          
     141                                    wx.OK | wx.ICON_EXCLAMATION) 
     142            dial.ShowModal() 
     143 
    168144    def get_file_path(self, path): 
    169145        """ 
     
    171147        """ 
    172148        if os.path.isdir(path): 
    173             return [os.path.join(os.path.abspath(path), 
    174                                   file) for file in os.listdir(path)] 
    175     
     149            return [os.path.join(os.path.abspath(path), filename) for filename in os.listdir(path)] 
     150 
    176151    def _process_data_and_errors(self, item, p_file, output, message): 
    177152        """ 
     
    186161        output[data.id] = data 
    187162        return output, message, data_error 
    188     
     163 
    189164    def get_data(self, path, format=None): 
    190165        """ 
     
    198173        for p_file in path: 
    199174            info = "info" 
    200             basename  = os.path.basename(p_file) 
     175            basename = os.path.basename(p_file) 
    201176            _, extension = os.path.splitext(basename) 
    202177            if extension.lower() in EXTENSIONS: 
     
    209184                logging.info(log_msg) 
    210185                continue 
    211          
     186 
    212187            try: 
    213188                message = "Loading Data... " + str(p_file) + "\n" 
    214189                self.load_update(output=output, message=message, info=info) 
    215                 temp =  self.loader.load(p_file, format) 
     190                temp = self.loader.load(p_file, format) 
    216191                if temp.__class__.__name__ == "list": 
    217192                    for item in temp: 
    218193                        output, error_message, data_error = \ 
    219                             self._process_data_and_errors(item,  
    220                                                           p_file,  
    221                                                           output,  
     194                            self._process_data_and_errors(item, 
     195                                                          p_file, 
     196                                                          output, 
    222197                                                          error_message) 
    223198                else: 
    224199                    output, error_message, data_error = \ 
    225                             self._process_data_and_errors(temp,  
    226                                                           p_file,  
    227                                                           output,  
     200                            self._process_data_and_errors(temp, 
     201                                                          p_file, 
     202                                                          output, 
    228203                                                          error_message) 
    229204            except: 
     
    243218                error_message = base_message + error_message 
    244219            else: 
    245                 error_message += "%s\n"% str(p_file) 
     220                error_message += "%s\n" % str(p_file) 
    246221            info = "error" 
    247             self.load_update(output=output, message=error_message,  
    248                                   info=info) 
    249                  
     222            self.load_update(output=output, message=error_message, info=info) 
     223 
    250224        else: 
    251225            message = "Loading Data Complete! " 
    252226        message += log_msg 
    253227        self.load_complete(output=output, error_message=error_message, 
    254                        message=message, path=path, info=info) 
    255              
     228                           message=message, path=path, info=info) 
     229 
    256230    def load_update(self, output=None, message="", info="warning"): 
    257231        """ 
     
    259233        """ 
    260234        if message != "": 
    261             wx.PostEvent(self.parent, StatusEvent(status=message, info='info',  
     235            wx.PostEvent(self.parent, StatusEvent(status=message, info='info', 
    262236                                                  type="progress")) 
    263     def load_complete(self, output, message="", error_message="", path=None,  
     237    def load_complete(self, output, message="", error_message="", path=None, 
    264238                      info="warning"): 
    265239        """ 
    266240         post message to  status bar and return list of data 
    267241        """ 
    268         wx.PostEvent(self.parent, StatusEvent(status=message,  
     242        wx.PostEvent(self.parent, StatusEvent(status=message, 
    269243                                              info=info, 
    270244                                              type="stop")) 
    271         #if error_message != "": 
     245        # if error_message != "": 
    272246        #    self.load_error(error_message) 
    273247        self.parent.add_data(data_list=output) 
    274     
    275      
    276          
    277     
     248 
     249 
     250 
  • src/sas/guiframe/local_perspectives/data_loader/load_thread.py

    r79492222 rb9dbd6b  
    1  
     1""" 
     2    Loading thread 
     3""" 
    24import time 
    35import sys 
     
    68from sas.data_util.calcthread import CalcThread 
    79 
    8          
     10 
    911EXTENSIONS = ['.svs', '.prv', '.inv', '.fitv'] 
    1012 
     
    1719                 transform_data=None, 
    1820                 completefn=None, 
    19                  updatefn   = None, 
    20                  yieldtime  = 0.01, 
    21                  worktime   = 0.01 
    22                  ): 
     21                 updatefn=None, 
     22                 yieldtime=0.01, 
     23                 worktime=0.01): 
    2324        CalcThread.__init__(self, completefn, 
    24                  updatefn, 
    25                  yieldtime, 
    26                  worktime) 
     25                            updatefn, 
     26                            yieldtime, 
     27                            worktime) 
    2728        self.load_state_flag = flag 
    2829        self.transform_data = transform_data 
    2930        self.list_path = path 
    30         #Instantiate a loader  
     31        # Instantiate a loader 
    3132        self.loader = loader 
    3233        self.message = "" 
    33         self.starttime = 0   
     34        self.starttime = 0 
    3435        self.updatefn = updatefn 
    35          
     36 
    3637    def isquit(self): 
    3738        """ 
     
    4142            CalcThread.isquit(self) 
    4243        except KeyboardInterrupt: 
    43             raise KeyboardInterrupt    
    44          
    45          
     44            raise KeyboardInterrupt 
     45 
    4646    def compute(self): 
    4747        """ 
     
    5252        error_message = "" 
    5353        for path in self.list_path: 
    54             basename  = os.path.basename(path) 
    55             root, extension = os.path.splitext(basename) 
     54            basename = os.path.basename(path) 
     55            _, extension = os.path.splitext(basename) 
    5656            if self.load_state_flag: 
    5757                if extension.lower() in EXTENSIONS: 
     
    6161                    pass 
    6262            try: 
    63                 temp =  self.loader.load(path) 
    64                 elapsed = time.time() - self.starttime 
     63                temp = self.loader.load(path) 
    6564                if temp.__class__.__name__ == "list": 
    6665                    for item in temp: 
     
    7776                error_message += str(sys.exc_value) + "\n" 
    7877                self.updatefn(output=output, message=error_message) 
    79                  
     78 
    8079        message = "Loading Complete!" 
    8180        self.complete(output=output, error_message=error_message, 
    82                        message=message, path=self.list_path) 
    83              
    84     
    85        
     81                      message=message, path=self.list_path) 
  • src/sas/guiframe/local_perspectives/plotting/plotting.py

    r79492222 rb9dbd6b  
    335335            self.create_panel_helper(new_panel, data, group_id, title)  
    336336        return 
    337         
    338     def help(self, evt): 
    339         """ 
    340         Show a general help dialog.  
    341         """ 
    342         from help_panel import  HelpWindow 
    343         frame = HelpWindow(None, -1)  
    344         if hasattr(frame, "IsIconized"): 
    345             if not frame.IsIconized(): 
    346                 try: 
    347                     icon = self.parent.GetIcon() 
    348                     frame.SetIcon(icon) 
    349                 except: 
    350                     pass   
    351337        frame.Show(True) 
Note: See TracChangeset for help on using the changeset viewer.