From b66999618067c314d16e0d0f6d7cad2ed6dfe0f0 Mon Sep 17 00:00:00 2001 From: David Levanon Date: Thu, 24 Sep 2020 13:39:42 +0300 Subject: [PATCH] prevent json layout and profile from being saved to the global config file --- terminatorlib/config.py | 6 ++++++ terminatorlib/configjson.py | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 4abc564b..371e534a 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -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] diff --git a/terminatorlib/configjson.py b/terminatorlib/configjson.py index 02872791..d6b5972b 100644 --- a/terminatorlib/configjson.py +++ b/terminatorlib/configjson.py @@ -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