Ignore:
Timestamp:
Mar 5, 2015 10:29:42 AM (10 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:
dca6188
Parents:
74f419d
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/perspectives/invariant/report_dialog.py

    re8bb5b6 r78a205a  
    11 
    22################################################################################ 
    3 #This software was developed by the University of Tennessee as part of the 
    4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    5 #project funded by the US National Science Foundation.  
     3# This software was developed by the University of Tennessee as part of the 
     4# Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5# project funded by the US National Science Foundation. 
    66# 
    7 #See the license text in license.txt 
     7# See the license text in license.txt 
    88# 
    9 #copyright 2009, University of Tennessee 
     9# copyright 2009, University of Tennessee 
    1010################################################################################ 
    1111 
    1212""" 
    13 Dialog report panel to show and summarize the results of  
     13Dialog report panel to show and summarize the results of 
    1414the invariant calculation. 
    1515""" 
    1616import wx 
    1717import os 
    18 import wx.html as html 
    19   
     18import sys 
     19import logging 
     20 
    2021from sas.guiframe.report_dialog import BaseReportDialog 
    2122 
    2223class ReportDialog(BaseReportDialog): 
    2324    """ 
    24     The report dialog box.  
     25    The report dialog box. 
    2526    """ 
    26      
    27     def __init__(self,  report_list, *args, **kwds): 
     27 
     28    def __init__(self, report_list, *args, **kwds): 
    2829        """ 
    2930        Initialization. The parameters added to Dialog are: 
    30          
     31 
    3132        :param report_list: list of html_str, text_str, image 
    3233        from invariant_state 
     
    4647        Save 
    4748        """ 
    48         #todo: complete saving fig file and as a txt file 
     49        # todo: complete saving fig file and as a txt file 
    4950        dlg = wx.FileDialog(self, "Choose a file", 
    5051                            wildcard=self.wild_card, 
    51                             style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 
    52         dlg.SetFilterIndex(0) #Set .html files to be default 
     52                            style=wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) 
     53        dlg.SetFilterIndex(0)  # Set .html files to be default 
    5354 
    5455        if dlg.ShowModal() != wx.ID_OK: 
     
    5758 
    5859        fName = dlg.GetPath() 
    59         ext_num = dlg.GetFilterIndex()   
    60         #set file extensions   
     60        ext_num = dlg.GetFilterIndex() 
     61        # set file extensions 
    6162        if ext_num == (0 + 2 * self.index_offset): 
    6263            # TODO: Sort this case out 
     
    6667            dlg.Destroy() 
    6768 
    68             #pic (png) file path/name 
     69            # pic (png) file path/name 
    6970            pic_fname = os.path.splitext(fName)[0] + img_ext 
    7071            # save the image for use with pdf writer 
     
    7374            # put the image file path in the html data 
    7475            html = self.report_list[0] % str(pic_fname) 
    75              
     76 
    7677            # make/open file in case of absence 
    7778            f = open(fName, 'w') 
     
    7980            # write pdf as a pdf file 
    8081            pdf = self.HTML2PDF(data=html, filename=fName) 
    81              
    82             #open pdf 
     82 
     83            # open pdf 
    8384            if pdf: 
    8485                try: 
    85                     #Windows 
     86                    # Windows 
    8687                    os.startfile(str(fName)) 
    8788                except: 
    8889                    try: 
    89                         #Mac 
    90                         os.system("open %s"% fName) 
     90                        # Mac 
     91                        os.system("open %s" % fName) 
    9192                    except: 
    92                         #DO not open 
    93                         pass 
    94             #delete image file 
     93                        # DO not open 
     94                        logging.error("Could not open file: %s" % sys.exc_value) 
     95            # delete image file 
    9596            os.remove(pic_fname) 
    9697            return 
     
    100101            report_frame = self.report_list[0] 
    101102        elif ext_num == (2 - self.index_offset): 
    102             ext = '.txt'    
     103            ext = '.txt' 
    103104            # changing the image extension actually changes the image 
    104105            # format on saving 
     
    108109            return 
    109110 
    110         #file name      
     111        # file name 
    111112        fName = os.path.splitext(fName)[0] + ext 
    112113        dlg.Destroy() 
    113         #pic (png) file path/name 
     114        # pic (png) file path/name 
    114115        pic_fname = os.path.splitext(fName)[0] + img_ext 
    115         #put the image path in html string 
     116        # put the image path in html string 
    116117        if ext_num == (1 - self.index_offset): 
    117118            report = report_frame % os.path.basename(pic_fname) 
     
    120121        f.write(report) 
    121122        f.close() 
    122         #save png file using pic_fname 
     123        # save png file using pic_fname 
    123124        self.report_list[2].savefig(pic_fname) 
    124          
Note: See TracChangeset for help on using the changeset viewer.