MCPcopy Index your code
hub / github.com/pyload/pyload / ConfigParser

Class ConfigParser

module/gui/CoreConfigParser.py:11–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10########################################################################
11class ConfigParser:
12
13 #----------------------------------------------------------------------
14 def __init__(self, configdir):
15 """Constructor"""
16 self.configdir = configdir
17 self.config = {}
18
19 if self.checkVersion():
20 self.readConfig()
21
22 #----------------------------------------------------------------------
23 def checkVersion(self):
24
25 if not exists(join(self.configdir, "pyload.conf")):
26 return False
27 f = open(join(self.configdir, "pyload.conf"), "rb")
28 v = f.readline()
29 f.close()
30 v = v[v.find(":")+1:].strip()
31
32 if int(v) < CONF_VERSION:
33 return False
34
35 return True
36
37 #----------------------------------------------------------------------
38 def readConfig(self):
39 """reads the config file"""
40
41 self.config = self.parseConfig(join(self.configdir, "pyload.conf"))
42
43
44 #----------------------------------------------------------------------
45 def parseConfig(self, config):
46 """parses a given configfile"""
47
48 f = open(config)
49
50 config = f.read()
51
52 config = config.split("\n")[1:]
53
54 conf = {}
55
56 section, option, value, typ, desc = "","","","",""
57
58 listmode = False
59
60 for line in config:
61
62 line = line.rpartition("#") # removes comments
63
64 if line[1]:
65 line = line[0]
66 else:
67 line = line[2]
68

Callers 2

slotConnectMethod · 0.90
CNLServer.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected