Changeset 27b7acc in sasview


Ignore:
Timestamp:
Apr 3, 2014 5:28:51 PM (10 years ago)
Author:
butler
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:
bbd97e5
Parents:
34dbaf4
Message:

converted stored category file from pickle to json and a bit of cleanup

Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • sansview/installer.iss

    r386b313 r27b7acc  
    7373Source: "dist\plugin_models\*"; DestDir: "{userdesktop}\..\.sasview\plugin_models";     Flags: recursesubdirs createallsubdirs 
    7474Source: "dist\config\custom_config.py"; DestDir: "{userdesktop}\..\.sasview\config";    Flags: recursesubdirs createallsubdirs 
    75 Source: "dist\default_categories.p";    DestDir: "{userdesktop}\..\.sasview";   DestName: "serialized_cat.p"; 
     75Source: "dist\default_categories.json";    DestDir: "{userdesktop}\..\.sasview";        DestName: "serialized_cat.json"; 
    7676;       NOTE: Don't use "Flags: ignoreversion" on any shared system files 
    7777 
  • sansview/installer_generator.py

    rd73a274 r27b7acc  
    201201    msg += """Source: "dist\config\custom_config.py";\tDestDir: "{userdesktop}\..\.sasview\config";\t"""  
    202202    msg += """Flags: recursesubdirs createallsubdirs\n""" 
    203     msg += """Source: "dist\default_categories.p";    DestDir: "{userdesktop}\..\.sasview";\t"""  
    204     msg += """DestName: "serialized_cat.p";\n""" 
     203    msg += """Source: "dist\default_categories.json";    DestDir: "{userdesktop}\..\.sasview";\t"""  
     204    msg += """DestName: "serialized_cat.json";\n""" 
    205205    msg += """;\tNOTE: Don't use "Flags: ignoreversion" on any shared system files""" 
    206206    return msg 
  • sansview/setup_exe.py

    r2f2d9d0 r27b7acc  
    271271    data_files.append(('.', [f])) 
    272272 
    273 f = 'default_categories.p' 
     273f = 'default_categories.json' 
    274274if os.path.isfile(f): 
    275275    data_files.append(('.', [f])) 
  • sansview/setup_mac.py

    r397b4e7 r27b7acc  
    5555APP = ['sansview.py'] 
    5656DATA_FILES += ['images','test','media', 'custom_config.py', 'local_config.py', 
    57                'default_categories.p'] 
     57               'default_categories.json'] 
    5858if os.path.isfile("BUILD_NUMBER"): 
    5959    DATA_FILES.append("BUILD_NUMBER") 
  • setup.py

    r307fa4f r27b7acc  
    4646    if os.path.isfile(f_path): 
    4747        os.remove(f_path) 
    48     f_path = os.path.join(sans_dir, "serialized_cat.p") 
     48    f_path = os.path.join(sans_dir, "serialized_cat.json") 
    4949    if os.path.isfile(f_path): 
    5050        os.remove(f_path) 
     
    321321package_dir["sans.sansview"] = "sansview" 
    322322package_data['sans.sansview'] = ['images/*', 'media/*', 'test/*',  
    323                                  'default_categories.p'] 
     323                                 'default_categories.json'] 
    324324packages.append("sans.sansview") 
    325325 
  • src/sans/guiframe/CategoryInstaller.py

    r64beda4 r27b7acc  
    1212import sys 
    1313import shutil 
    14 import cPickle as pickle 
     14import json 
    1515from collections import defaultdict 
    1616 
    17 USER_FILE = 'serialized_cat.p' 
     17USER_FILE = 'serialized_cat.json' 
    1818 
    1919class CategoryInstaller: 
     
    4545     
    4646    @staticmethod 
    47     def _get_default_cat_p_dir(): 
     47    def _get_default_cat_file_dir(): 
    4848        """ 
    49         returns the dir where default_cat.p should be 
     49        returns the dir where default_cat.j should be 
    5050        """ 
    5151        # The default categories file is usually found with the code, except 
     
    5353        # py2exe (it will be in the exec dir). 
    5454        import sans.sansview 
    55         cat_file = "default_categories.p" 
     55        cat_file = "default_categories.json" 
    5656         
    5757        possible_cat_file_paths = [ 
     
    111111    def get_user_file(): 
    112112        """ 
    113         returns the user data file, eg .sasview/serialized_cat.p 
     113        returns the user data file, eg .sasview/serialized_cat.json 
    114114        """ 
    115115        return os.path.join(CategoryInstaller._get_home_dir(), 
     
    120120        """ 
    121121        returns the path of the default file 
    122         e.g. blahblah/default_categories.p 
     122        e.g. blahblah/default_categories.json 
    123123        """ 
    124124        return os.path.join(\ 
    125             CategoryInstaller._get_default_cat_p_dir(), "default_categories.p") 
     125            CategoryInstaller._get_default_cat_file_dir(), "default_categories.json") 
    126126         
    127127    @staticmethod 
     
    129129        """ 
    130130        the main method of this class 
    131         makes sure serialized_cat.p exists and if not 
     131        makes sure serialized_cat.json exists and if not 
    132132        compile it and install 
    133133        :param homefile: Override the default home directory 
     
    146146        else: 
    147147            cat_file = open(default_file, 'rb') 
    148         master_category_dict = pickle.Unpickler(cat_file).load() 
     148        master_category_dict = json.load(cat_file) 
     149#        master_category_dict = pickle.Unpickler(cat_file).load() 
    149150        (by_model_dict, model_enabled_dict) = \ 
    150151                CategoryInstaller._regenerate_model_dict(master_category_dict) 
     
    173174                                                          model_enabled_dict) 
    174175             
    175             pickle.dump( master_category_dict, 
     176            json.dump( master_category_dict, 
    176177                         open(serialized_file, 'wb') ) 
    177178             
  • src/sans/guiframe/CategoryManager.py

    r51f14603 r27b7acc  
    1515from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin 
    1616from collections import defaultdict 
    17 import cPickle as pickle 
     17import json 
    1818from sans.guiframe.events import ChangeCategoryEvent 
    1919from sans.guiframe.CategoryInstaller import CategoryInstaller 
     
    294294        cat_file = open(CategoryInstaller.get_user_file(), 'wb') 
    295295 
    296         pickle.dump( self.master_category_dict, cat_file ) 
     296        json.dump(self.master_category_dict, cat_file ) 
    297297         
    298298        cat_file.close() 
     
    303303        """ 
    304304        try: 
    305                 file = CategoryInstaller.get_user_file() 
    306                 if os.path.isfile(file): 
    307                     cat_file = open(file, 'rb') 
    308                     self.master_category_dict = pickle.load(cat_file) 
    309                 else: 
    310                         cat_file = open(CategoryInstaller.get_default_file(), 'rb') 
    311                         self.master_category_dict = pickle.load(cat_file) 
    312                 cat_file.close() 
     305            file = CategoryInstaller.get_user_file() 
     306            if os.path.isfile(file): 
     307                cat_file = open(file, 'rb') 
     308#               self.master_category_dict = pickle.load(cat_file) 
     309                self.master_category_dict = json.load(cat_file) 
     310            else: 
     311                cat_file = open(CategoryInstaller.get_default_file(), 'rb') 
     312#                       self.master_category_dict = pickle.load(cat_file) 
     313                self.master_category_dict = json.load(cat_file) 
     314            cat_file.close() 
    313315        except IOError: 
    314316            print 'Problem reading in category file. Please review' 
  • src/sans/guiframe/customdir.py

    r5777106 r27b7acc  
    3535        os.makedirs(dir) 
    3636    file = os.path.join(dir, "custom_config.py") 
    37     u_dir = _find_usersasview_dir() 
    38     cat_file = os.path.join(u_dir, "serialized_cat.p") 
    39     # Place example user models as needed 
     37    cat_file = CategoryInstaller.get_user_file() 
     38    # If the user category file doesn't exist copy the default to 
     39    # the user directory 
    4040    if not os.path.isfile(cat_file): 
    4141        try: 
  • src/sans/perspectives/fitting/basepage.py

    r34dbaf4 r27b7acc  
    1010import math 
    1111import string 
    12 import cPickle as pickle 
    13 #import shutil 
     12import json 
    1413from collections import defaultdict 
    1514from wx.lib.scrolledpanel import ScrolledPanel 
     
    35853584            if not os.path.isfile(categorization_file): 
    35863585                categorization_file = CategoryInstaller.get_default_file() 
    3587             cat_file = open(categorization_file, 'rb') 
    3588                              
    3589             self.master_category_dict = pickle.load(cat_file) 
     3586            cat_file = open(categorization_file, 'rb')                            
     3587            self.master_category_dict = json.load(cat_file) 
    35903588            self._regenerate_model_dict() 
    35913589            cat_file.close() 
  • src/sans/perspectives/fitting/models.py

    r5777106 r27b7acc  
    948948 
    949949    CategoryInstaller.check_install(model_list=cat_model_list) 
    950      
    951950    def findModels(self): 
    952951        return self.__modelmanager.findModels() 
Note: See TracChangeset for help on using the changeset viewer.