-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.py
31 lines (23 loc) · 949 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# @Time: 2021/3/21 11:40
import configparser
import os
from logger import logger
class Config(object):
def __init__(self, config_file='config_bili.ini'):
self._path = os.path.join(os.getcwd(), config_file)
if not os.path.exists(self._path):
raise FileNotFoundError("No such file: config_bili.ini")
self._config = configparser.ConfigParser()
self._config.read(self._path, encoding='utf-8-sig')
self._configRaw = configparser.RawConfigParser()
self._configRaw.read(self._path, encoding='utf-8-sig')
def get(self, section, name):
logger.info('加载配置{}下的{}'.format(section, name))
return self._config.get(section, name)
def get_raw(self, section, name):
logger.info('加载配置{}下的{}'.format(section, name))
return self._configRaw.get(section, name)
global_config = Config()