From 8462d2f2aaeb348311ce24b4ea057ea64e26670a Mon Sep 17 00:00:00 2001 From: RicterZ Date: Thu, 26 Nov 2020 17:52:10 +0800 Subject: [PATCH] use dict.update to update config values --- nhentai/cmdline.py | 2 +- nhentai/constant.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nhentai/cmdline.py b/nhentai/cmdline.py index 59dadac..532beb4 100644 --- a/nhentai/cmdline.py +++ b/nhentai/cmdline.py @@ -43,7 +43,7 @@ def load_config(): try: with open(constant.NHENTAI_CONFIG_FILE, 'r') as f: - constant.CONFIG = json.load(f) + constant.CONFIG.update(json.load(f)) except json.JSONDecodeError: logger.error('Failed to load config file.') write_config() diff --git a/nhentai/constant.py b/nhentai/constant.py index e27765e..7d8df2f 100644 --- a/nhentai/constant.py +++ b/nhentai/constant.py @@ -1,6 +1,7 @@ # coding: utf-8 from __future__ import unicode_literals, print_function import os +import copy import tempfile try: @@ -29,10 +30,10 @@ NHENTAI_HOME = os.path.join(os.getenv('HOME', tempfile.gettempdir()), '.nhentai' NHENTAI_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3') NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json') + CONFIG = { 'proxy': {}, 'cookie': '', 'language': '', 'template': '', } -