-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
66 lines (54 loc) · 1.74 KB
/
config.py
File metadata and controls
66 lines (54 loc) · 1.74 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
# load config
import json
import os
class Config(object):
mysqlconfig=None
githubtoken=None
nodesconfig=None
nodeconfig=None
path="/home/zh/PycharmProjects/project"
@classmethod
def init_mysql_config(cls):
if not cls.mysqlconfig:
path=os.path.join(cls.path,"mysql.json")
path=os.path.abspath(path)
with open(path,"r") as fp:
cls.mysqlconfig=json.load(fp)
return cls.mysqlconfig
@classmethod
def init_node_config(cls):
if not cls.nodeconfig:
path=os.path.join(cls.path,"node.json")
path=os.path.abspath(path)
with open(path,"r") as fp:
cls.nodeconfig=json.load(fp)
return cls.nodeconfig
@classmethod
def init_nodes_config(cls):
if not cls.nodesconfig:
path=os.path.join(cls.path,"nodes.json")
path=os.path.abspath(path)
with open(path,"r") as fp:
cls.nodesconfig=json.load(fp)
return cls.nodesconfig
@classmethod
def _init_gihtub_token(cls):
if not cls.githubtoken:
path=os.path.join(cls.path,"token.json")
path=os.path.abspath(path)
with open(path,"r") as fp:
cls.githubtoken=json.load(fp)
return cls.githubtoken
@classmethod
def init(cls):
cls.init_mysql_config()
cls._init_gihtub_token()
cls.init_node_config()
cls.init_nodes_config()
Config.init()
def test():
print(f"token={Config.githubtoken}")
print(f"node={Config.nodesconfig['github']}")
print(f"node={Config.nodeconfig['github']}")
if __name__ == '__main__':
test()