MCPcopy
hub / github.com/pyload/pyload / ConfigParser

Class ConfigParser

module/ConfigParser.py:22–361  ·  view source on GitHub ↗

holds and manage the configuration current dict layout: { section : { option : { value: type: desc: } desc: }

Source from the content-addressed store, hash-verified

20CONF_VERSION = 1
21
22class ConfigParser:
23 """
24 holds and manage the configuration
25
26 current dict layout:
27
28 {
29
30 section : {
31 option : {
32 value:
33 type:
34 desc:
35 }
36 desc:
37
38 }
39
40
41 """
42
43 CONFLINE = re.compile(r'^\s*(?P<T>.+?)\s+(?P<N>[^ ]+?)\s*:\s*"(?P<D>.+?)"\s*=\s?(?P<V>.*)')
44
45 def __init__(self):
46 """Constructor"""
47 self.config = {} # the config values
48 self.plugin = {} # the config for plugins
49 self.oldRemoteData = {}
50
51 self.pluginCB = None # callback when plugin config value is changed
52
53 self.checkVersion()
54
55 self.readConfig()
56
57 self.deleteOldPlugins()
58
59
60 def checkVersion(self, n=0):
61 """determines if config need to be copied"""
62 try:
63 if not exists("pyload.conf"):
64 copy(join(pypath, "module", "config", "default.conf"), "pyload.conf")
65 chmod("pyload.conf", 0600)
66
67 if not exists("plugin.conf"):
68 f = open("plugin.conf", "wb")
69 f.write("version: " + str(CONF_VERSION))
70 f.close()
71 chmod("plugin.conf", 0600)
72
73 f = open("pyload.conf", "rb")
74 v = f.readline()
75 f.close()
76 v = v[v.find(":") + 1:].strip()
77
78 if not v or int(v) < CONF_VERSION:
79 copy(join(pypath, "module", "config", "default.conf"), "pyload.conf")

Callers 3

__init__Method · 0.90
startMethod · 0.90
ConfigParser.pyFile · 0.70

Calls 1

compileMethod · 0.80

Tested by

no test coverage detected