Changeset cb64d86 in sasview


Ignore:
Timestamp:
Feb 22, 2019 2:25:03 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
82d88d5
Parents:
61379c2e
Message:

src/sas/sasgui/guiframe/CategoryInstaller.py

consistent python 2/3 handling of json dump

Location:
src/sas/sasgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/CategoryInstaller.py

    r5251ec6 rcb64d86  
    2020 
    2121logger = logging.getLogger(__name__) 
     22 
     23if sys.version_info[0] > 2: 
     24    def json_dump(obj, filename): 
     25        with open(filename, 'w', newline='\n') as fd: 
     26            json.dump(obj, fd) 
     27else: # CRUFT: python 2.7 support 
     28    def json_dump(obj, filename): 
     29        with open(filename, 'wb') as fd: 
     30            json.dump(obj, fd) 
    2231 
    2332class CategoryInstaller(object): 
     
    171180                                                          model_enabled_dict) 
    172181 
    173             json.dump(master_category_dict, open(serialized_file, 'w')) 
     182            json_dump(master_category_dict, serialized_file) 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r5251ec6 rcb64d86  
    1212import logging 
    1313import traceback 
    14 try: 
     14try: # CRUFT: python 2.x 
    1515    from Queue import Queue 
    1616except ImportError: 
  • src/sas/sasgui/plottools/toolbar.py

    r5251ec6 rcb64d86  
    3939    try: save_figure = NavigationToolbar2WxAgg.save 
    4040    except AttributeError: pass 
    41      
     41 
    4242    def _init_toolbar(self): 
    4343        self._parent = self.canvas.GetParent() 
     
    6666        # todo: get new bitmap 
    6767        # todo: update with code from matplotlib/backends/backend_wx.py 
    68         is_phoenix = 'phoenix' in wx.PlatformInfo 
    69         if is_phoenix: # wx phoenix >= 4.0.0b2 
     68        if 'phoenix' in wx.PlatformInfo: # wx phoenix >= 4.0.0b2 
    7069            self.AddCheckTool(self._NTB2_PAN, "Pan", _load_bitmap('move.png'), 
    7170                              shortHelp='Pan', 
Note: See TracChangeset for help on using the changeset viewer.