Changeset 27b7acc in sasview for src/sans/guiframe
- Timestamp:
- Apr 3, 2014 7:28:51 PM (11 years ago)
- 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
- Location:
- src/sans/guiframe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/guiframe/CategoryInstaller.py
r64beda4 r27b7acc 12 12 import sys 13 13 import shutil 14 import cPickle as pickle14 import json 15 15 from collections import defaultdict 16 16 17 USER_FILE = 'serialized_cat. p'17 USER_FILE = 'serialized_cat.json' 18 18 19 19 class CategoryInstaller: … … 45 45 46 46 @staticmethod 47 def _get_default_cat_ p_dir():47 def _get_default_cat_file_dir(): 48 48 """ 49 returns the dir where default_cat. pshould be49 returns the dir where default_cat.j should be 50 50 """ 51 51 # The default categories file is usually found with the code, except … … 53 53 # py2exe (it will be in the exec dir). 54 54 import sans.sansview 55 cat_file = "default_categories. p"55 cat_file = "default_categories.json" 56 56 57 57 possible_cat_file_paths = [ … … 111 111 def get_user_file(): 112 112 """ 113 returns the user data file, eg .sasview/serialized_cat. p113 returns the user data file, eg .sasview/serialized_cat.json 114 114 """ 115 115 return os.path.join(CategoryInstaller._get_home_dir(), … … 120 120 """ 121 121 returns the path of the default file 122 e.g. blahblah/default_categories. p122 e.g. blahblah/default_categories.json 123 123 """ 124 124 return os.path.join(\ 125 CategoryInstaller._get_default_cat_ p_dir(), "default_categories.p")125 CategoryInstaller._get_default_cat_file_dir(), "default_categories.json") 126 126 127 127 @staticmethod … … 129 129 """ 130 130 the main method of this class 131 makes sure serialized_cat. pexists and if not131 makes sure serialized_cat.json exists and if not 132 132 compile it and install 133 133 :param homefile: Override the default home directory … … 146 146 else: 147 147 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() 149 150 (by_model_dict, model_enabled_dict) = \ 150 151 CategoryInstaller._regenerate_model_dict(master_category_dict) … … 173 174 model_enabled_dict) 174 175 175 pickle.dump( master_category_dict,176 json.dump( master_category_dict, 176 177 open(serialized_file, 'wb') ) 177 178 -
src/sans/guiframe/CategoryManager.py
r51f14603 r27b7acc 15 15 from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin 16 16 from collections import defaultdict 17 import cPickle as pickle17 import json 18 18 from sans.guiframe.events import ChangeCategoryEvent 19 19 from sans.guiframe.CategoryInstaller import CategoryInstaller … … 294 294 cat_file = open(CategoryInstaller.get_user_file(), 'wb') 295 295 296 pickle.dump(self.master_category_dict, cat_file )296 json.dump(self.master_category_dict, cat_file ) 297 297 298 298 cat_file.close() … … 303 303 """ 304 304 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() 313 315 except IOError: 314 316 print 'Problem reading in category file. Please review' -
src/sans/guiframe/customdir.py
r5777106 r27b7acc 35 35 os.makedirs(dir) 36 36 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 needed37 cat_file = CategoryInstaller.get_user_file() 38 # If the user category file doesn't exist copy the default to 39 # the user directory 40 40 if not os.path.isfile(cat_file): 41 41 try:
Note: See TracChangeset
for help on using the changeset viewer.