-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathConfig.py
82 lines (76 loc) · 4.07 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import pathlib
import configparser
class newConfigparser(configparser.ConfigParser):
def __init__(self,defaults=None):
configparser.ConfigParser.__init__(self,defaults=None)
def optionxform(self, optionstr):
return optionstr
#
class Config(object):
def __init__(self):
self.exitAfterFinish=False
self.closeGamesAfterFinish=False
self.exitAfterFailure=False
self.closeGamesAfterFailure=True
self.exitIfOccupied=False
self.closeGamesIfOccupied=True
self.exitIfFoodNotEnough=False
self.closeGamesIfFoodNotEnough=True
self.isFullTeam=False
self.replaceShikigamiIfFull=True
#
def __init__(self,configFilePath):
self.exitAfterFinish=False
self.closeGamesAfterFinish=False
self.exitAfterFailure=False
self.closeGamesAfterFailure=True
self.exitIfOccupied=False
self.closeGamesIfOccupied=True
self.exitIfFoodNotEnough=False
self.closeGamesIfFoodNotEnough=True
self.isFullTeam=False
self.replaceShikigamiIfFull=True
configPraser=newConfigparser()
if (pathlib.Path(configFilePath).exists())==False:
configPraser["Options"]={"ExitAfterfinish":"False",
"CloseGamesAfterFinish":"False",
"ExitAfterFailure":"False",
"CloseGamesAfterFailure":"True",
"ExitIfOccupied":"False",
"CloseGamesIfOccupied":"True",
"ExitIfFoodNotEnough":"False",
"CloseGamesIfFoodNotEnough":"True",
"ExitIfDisconnected":"False",
"CloseGamesIfDisconnected":"True",
"IsFullTeam":"False",
"ReplaceIfShikigamiFull":"True"}
with open(configFilePath, 'w') as configFile:
configPraser.write(configFile)
return
configPraser.read(configFilePath)
if configPraser.has_section("Options"):
options=configPraser["Options"]
if configPraser.has_option("Options","ExitAfterfinish"):
self.exitAfterFinish=options.getboolean("ExitAfterfinish")
if configPraser.has_option("Options","CloseGamesAfterFinish"):
self.closeGamesAfterFinish=options.getboolean("CloseGamesAfterFinish")
if configPraser.has_option("Options","ExitAfterFailure"):
self.exitAfterFailure=options.getboolean("ExitAfterFailure")
if configPraser.has_option("Options","CloseGamesAfterFailure"):
self.closeGamesAfterFailure=options.getboolean("CloseGamesAfterFailure")
if configPraser.has_option("Options","ExitIfOccupied"):
self.exitIfOccupied=options.getboolean("ExitIfOccupied")
if configPraser.has_option("Options","CloseGamesIfOccupied"):
self.closeGamesIfOccupied=options.getboolean("CloseGamesIfOccupied")
if configPraser.has_option("Options","ExitIfFoodNotEnough"):
self.exitIfFoodNotEnough=options.getboolean("ExitIfFoodNotEnough")
if configPraser.has_option("Options","CloseGamesIfFoodNotEnough"):
self.closeGamesIfFoodNotEnough=options.getboolean("CloseGamesIfFoodNotEnough")
if configPraser.has_option("Options","ExitIfDisconnected"):
self.exitIfDisconnected=options.getboolean("ExitIfDisconnected")
if configPraser.has_option("Options","CloseGamesIfDisconnected"):
self.closeGamesIfDisconnected=options.getboolean("CloseGamesIfDisconnected")
if configPraser.has_option("Options","IsFullTeam"):
self.isFullTeam=options.getboolean("IsFullTeam")
if configPraser.has_option("Options","ReplaceIfShikigamiFull"):
self.replaceShikigamiIfFull=options.getboolean("ReplaceIfShikigamiFull")