use dict.update to update config values

This commit is contained in:
RicterZ 2020-11-26 17:52:10 +08:00
parent 51074ee948
commit 8462d2f2aa
2 changed files with 3 additions and 2 deletions

View File

@ -43,7 +43,7 @@ def load_config():
try: try:
with open(constant.NHENTAI_CONFIG_FILE, 'r') as f: with open(constant.NHENTAI_CONFIG_FILE, 'r') as f:
constant.CONFIG = json.load(f) constant.CONFIG.update(json.load(f))
except json.JSONDecodeError: except json.JSONDecodeError:
logger.error('Failed to load config file.') logger.error('Failed to load config file.')
write_config() write_config()

View File

@ -1,6 +1,7 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function
import os import os
import copy
import tempfile import tempfile
try: 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_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3')
NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json') NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json')
CONFIG = { CONFIG = {
'proxy': {}, 'proxy': {},
'cookie': '', 'cookie': '',
'language': '', 'language': '',
'template': '', 'template': '',
} }