def begin_migration_old(self): project_file_path = self.window.project_file_name() debug('Project file path = {path}'.format(path=project_file_path), prefix='Jekyll Utility') if os.path.exists(project_file_path): with open(project_file_path, 'r+') as project_file: project_data = json.load(project_file) if not 'settings' in project_data: # No project settings found sublime.message_dialog('Unable to find project settings!') debug('Unable to find project settings.', prefix='Jekyll Utility', level='error') return settings = project_data['settings'] if 'Jekyll' in settings: # Create backup of current project settings file sublime.set_timeout(lambda: self.create_backup('project'), 100) jekyll_settings = settings['Jekyll'] for key in self.settings_to_swap: if key in jekyll_settings: jekyll_settings[self.settings_to_swap[ key]] = jekyll_settings[key] debug( 'Migrated old settings key "{key}" to new settings key "{swap}"' .format(key=key, swap=self.settings_to_swap[key]), prefix='Jekyll Utility', level='info') jekyll_settings.pop(key, None) debug('Deleted old settings key "{key}"'.format( key=key), prefix='Jekyll Utility', level='info') settings['Jekyll'] = jekyll_settings project_data['settings'] = settings project_file.seek(0) project_file.truncate() json.dump(project_data, project_file, indent=4, sort_keys=True) else: # No Jekyll project settings found sublime.message_dialog( 'Unable to find Jekyll in project settings!') debug('Unable to find Jekyll in project settings.', prefix='Jekyll Utility', level='error')
def begin_migration_old(self): project_file_path = self.window.project_file_name() debug("Project file path = {path}".format(path=project_file_path), prefix="Jekyll Utility") if os.path.exists(project_file_path): with open(project_file_path, "r+") as project_file: project_data = json.load(project_file) if not "settings" in project_data: # No project settings found sublime.message_dialog("Unable to find project settings!") debug("Unable to find project settings.", prefix="Jekyll Utility", level="error") return settings = project_data["settings"] if "Jekyll" in settings: # Create backup of current project settings file sublime.set_timeout(lambda: self.create_backup("project"), 100) jekyll_settings = settings["Jekyll"] for key in self.settings_to_swap: if key in jekyll_settings: jekyll_settings[self.settings_to_swap[key]] = jekyll_settings[key] debug( 'Migrated old settings key "{key}" to new settings key "{swap}"'.format( key=key, swap=self.settings_to_swap[key] ), prefix="Jekyll Utility", level="info", ) jekyll_settings.pop(key, None) debug( 'Deleted old settings key "{key}"'.format(key=key), prefix="Jekyll Utility", level="info", ) settings["Jekyll"] = jekyll_settings project_data["settings"] = settings project_file.seek(0) project_file.truncate() json.dump(project_data, project_file, indent=4, sort_keys=True) else: # No Jekyll project settings found sublime.message_dialog("Unable to find Jekyll in project settings!") debug("Unable to find Jekyll in project settings.", prefix="Jekyll Utility", level="error")
def default(self): self.clearDB() try: pointer = os.path.join(CWD, "settings.json") file = open(pointer, "r") defaults = json.load(file) file.close() except: print traceback.format_exc() defaults = {} for key in defaults.keys(): self.db.insert(str(key), defaults[key]) self.db.insert("version", self.db_version) self.db.commit()
def begin_migration_old(self): project_file_path = self.window.project_file_name() debug('Project file path = {path}'.format(path=project_file_path), prefix='Jekyll Utility') if os.path.exists(project_file_path): with open(project_file_path, 'r+') as project_file: project_data = json.load(project_file) if not 'settings' in project_data: # No project settings found sublime.message_dialog('Unable to find project settings!') debug('Unable to find project settings.', prefix='Jekyll Utility', level='error') return settings = project_data['settings'] if 'Jekyll' in settings: # Create backup of current project settings file sublime.set_timeout(lambda: self.create_backup('project'), 100) jekyll_settings = settings['Jekyll'] for key in self.settings_to_swap: if key in jekyll_settings: jekyll_settings[self.settings_to_swap[key]] = jekyll_settings[key] debug('Migrated old settings key "{key}" to new settings key "{swap}"'.format( key=key, swap=self.settings_to_swap[key] ), prefix='Jekyll Utility', level='info') jekyll_settings.pop(key, None) debug('Deleted old settings key "{key}"'.format(key=key), prefix='Jekyll Utility', level='info') settings['Jekyll'] = jekyll_settings project_data['settings'] = settings project_file.seek(0) project_file.truncate() json.dump(project_data, project_file, indent=4, sort_keys=True) else: # No Jekyll project settings found sublime.message_dialog('Unable to find Jekyll in project settings!') debug('Unable to find Jekyll in project settings.', prefix='Jekyll Utility', level='error')