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

File:
1 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) 
Note: See TracChangeset for help on using the changeset viewer.