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)
parser[section_name] = dict_diff(DEFAULTS[section_name], section)
from .configjson import JSON_PROFILE_NAME, JSON_LAYOUT_NAME
parser['profiles'] = {}
for profile in self.profiles:
if profile == JSON_PROFILE_NAME:
continue
dbg('ConfigBase::save: Processing profile: %s' % profile)
parser['profiles'][profile] = dict_diff(
DEFAULTS['profiles']['default'], self.profiles[profile])
parser['layouts'] = {}
for layout in self.layouts:
if layout == JSON_LAYOUT_NAME:
continue
dbg('ConfigBase::save: Processing layout: %s' % layout)
parser['layouts'][layout] = self.layouts[layout]

View File

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