Check config.yaml exists

This commit is contained in:
SuperSonic 2020-02-26 18:56:40 +08:00
parent b4f8f47ebc
commit 1b8ddd8c3d

View file

@ -6,11 +6,21 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/. file, You can obtain one at http://mozilla.org/MPL/2.0/.
""" """
import os
import yaml import yaml
class Yuuki_Config: class Yuuki_Config:
""" Configure Yuuki """ """
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! DO NOT TOUCH DEFAULT SETTINGS !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Please config the value you want to set though `config.yaml`.
It will overwrite these settings.
"""
connectInfo = { connectInfo = {
"Host": "", "Host": "",
@ -45,6 +55,7 @@ class Yuuki_Config:
} }
def __init__(self, config_path="config.yaml"): def __init__(self, config_path="config.yaml"):
assert os.path.isfile(config_path), "The configure file, `config.yaml` was not found."
with open(config_path, "r") as configfile: with open(config_path, "r") as configfile:
self.config = yaml.load(configfile, Loader=yaml.FullLoader) self.config = yaml.load(configfile, Loader=yaml.FullLoader)
self._yuuki_config() self._yuuki_config()