prevent json layout and profile from being saved to the global config file

This commit is contained in:
David Levanon 2020-09-24 13:39:42 +03:00 committed by David Levanon
parent 42b1915065
commit b669996180
2 changed files with 13 additions and 6 deletions

View File

@ -696,14 +696,20 @@ class ConfigBase(Borg):
section = getattr(self, section_name) section = getattr(self, section_name)
parser[section_name] = dict_diff(DEFAULTS[section_name], section) parser[section_name] = dict_diff(DEFAULTS[section_name], section)
from .configjson import JSON_PROFILE_NAME, JSON_LAYOUT_NAME
parser['profiles'] = {} parser['profiles'] = {}
for profile in self.profiles: for profile in self.profiles:
if profile == JSON_PROFILE_NAME:
continue
dbg('ConfigBase::save: Processing profile: %s' % profile) dbg('ConfigBase::save: Processing profile: %s' % profile)
parser['profiles'][profile] = dict_diff( parser['profiles'][profile] = dict_diff(
DEFAULTS['profiles']['default'], self.profiles[profile]) DEFAULTS['profiles']['default'], self.profiles[profile])
parser['layouts'] = {} parser['layouts'] = {}
for layout in self.layouts: for layout in self.layouts:
if layout == JSON_LAYOUT_NAME:
continue
dbg('ConfigBase::save: Processing layout: %s' % layout) dbg('ConfigBase::save: Processing layout: %s' % layout)
parser['layouts'][layout] = self.layouts[layout] parser['layouts'][layout] = self.layouts[layout]

View File

@ -5,10 +5,11 @@ import json
import copy import copy
from .config import Config from .config import Config
class ConfigJson(object):
JSON_PROFILE_NAME = "__internal_json_profile__" JSON_PROFILE_NAME = "__internal_json_profile__"
JSON_LAYOUT_NAME = "__internal_json_layout__" JSON_LAYOUT_NAME = "__internal_json_layout__"
class ConfigJson(object):
profile_to_use = 'default' profile_to_use = 'default'
def build_single_tab_layout(self, layoutjson, vertical): def build_single_tab_layout(self, layoutjson, vertical):
@ -158,13 +159,13 @@ class ConfigJson(object):
if 'profile' in configjson: if 'profile' in configjson:
profile = self.get_profile(configjson['profile'], config.base.profiles['default']) profile = self.get_profile(configjson['profile'], config.base.profiles['default'])
if profile: if profile:
config.base.profiles[self.JSON_PROFILE_NAME] = profile config.base.profiles[JSON_PROFILE_NAME] = profile
self.profile_to_use = self.JSON_PROFILE_NAME self.profile_to_use = JSON_PROFILE_NAME
if 'layout' in configjson: if 'layout' in configjson:
layout = self.get_layout(configjson['layout']) layout = self.get_layout(configjson['layout'])
if layout: if layout:
config.base.layouts[self.JSON_LAYOUT_NAME] = layout config.base.layouts[JSON_LAYOUT_NAME] = layout
return self.JSON_LAYOUT_NAME return JSON_LAYOUT_NAME
return None return None