-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConfig.py
53 lines (50 loc) · 1.88 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from configparser import ConfigParser
class Config:
isproxy = ''
https_proxy = ''
http_proxy = ''
listnum = 0
isdown_bigpic = ''
def __init__(self,path = './config.ini'):
config = ConfigParser()
try:
config.read(path,encoding='utf-8')
try:
self.isproxy = config.get('可选设置','isproxy')
if self.isproxy != 'yes' and self.isproxy != 'no':
self.isproxy = 'yes'
except Exception:
self.isproxy = 'yes'
try:
self.http_proxy = config.get('可选设置','http_proxy')
except Exception:
self.http_proxy = 'http://localhost:7890'
try:
self.https_proxy = config.get('可选设置','https_proxy')
except Exception:
self.https_proxy = 'http://localhost:7890'
try:
self.listnum = int(config.get('可选设置','listnum'))
except Exception:
self.listnum = 10
try:
self.isdown_bigpic = config.get('可选设置','isdown_bigpic')
if self.isdown_bigpic != 'yes' and self.isdown_bigpic != 'no':
self.isdown_bigpic = 'no'
except Exception:
self.isdown_bigpic = 'no'
except Exception:
self.isproxy = 'yes'
self.http_proxy = 'http://localhost:7890'
self.https_proxy = 'http://localhost:7890'
self.listnum = 10
self.isdown_bigpic = 'no'
def printconfig(self):
text = f'''
是否代理:{self.isproxy}
http:{self.http_proxy}
https:{self.https_proxy}
下载页数:{self.listnum}
是否下载原图:{self.isdown_bigpic}
'''
print(text)