Changeset 1155 for dassmodus/trunk
- Timestamp:
- Jun 14, 2013, 12:37:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dassmodus/trunk/dassmodus/nosferatu/nosferatu/tools/bacsource2configrules.py
r1153 r1155 39 39 RXP_RESOURCE = re.compile(r''' 40 40 ^(?:static\s+)?RES_ITEM(2)?\s+ 41 (?P<name>[^[]+)\[\]\s +=\s+\{\s*\n # First line with starting brace41 (?P<name>[^[]+)\[\]\s*=\s*\{\s*\n # First line with starting brace 42 42 (?P<items>.*?) # Non greedy search 43 \n }\s*;43 \n\s*}\s*; 44 44 ''', re.M|re.X|re.S) 45 45 46 46 47 47 RXP_ITEM = re.compile(r''' 48 ^\s +{"(?P<name>[^"]+)"\s*,48 ^\s*{\s*"(?P<name>[^"]+)"\s*, 49 49 \s*(?P<handler>[^,]+)\s*, 50 50 \s*(?P<value>[^,]+)\s*, 51 51 \s*(?P<code>[^,]+)\s*, 52 52 \s*(?P<flags>[^,]+)\s*, 53 \s*(?P<default_value> [^}]+)},?\s*53 \s*(?P<default_value>("[^"]+"|[^ ]+))\s+},.* 54 54 ''', re.X) 55 55 … … 163 163 164 164 def defvalue(type, name, value): 165 if type == 'store_opts': 166 if name in BOOL_FILESET_OPTIONS: 167 if value == 0: 168 defval = False 169 else: 170 defval = True 171 else: 172 defval = value 173 174 elif type == 'store_bool' or type == 'store_bit': 175 if value == 0 or value == '0' or value == 'false' or value == None: 176 defval = False 165 if value == "NULL": 166 defval = None 167 else: 168 if type == 'store_opts': 169 if name in BOOL_FILESET_OPTIONS: 170 if value == 0: 171 defval = False 172 else: 173 defval = True 174 else: 175 defval = value 176 elif type == 'store_bool' or type == 'store_bit': 177 if value == 0 or value == '0' or value == 'false' or value == None: 178 defval = False 179 else: 180 defval = True 181 elif type == 'store_name' or type == 'store_str': 182 #print "value:[" + value + "]" 183 if value == "NULL": 184 defval = None 185 else: 186 defval = CONF2VALUE.get(value,value) 177 187 else: 178 defval = True 179 else: 180 defval = CONF2VALUE.get(value,value) 188 defval = CONF2VALUE.get(value,value) 181 189 return defval 182 190 … … 215 223 216 224 def directives(daemon, conf): 225 #print "directives:", daemon, conf 217 226 res = conf.keys() 218 227 res.sort() … … 229 238 #for i, v in conf[r].iteritems(): 230 239 name = i 240 #print " ", name, 231 241 v = conf[r][i] 232 242 type = v["handler"] 243 #print "(type:", type, ")", 233 244 required = v["flags"] == "ITEM_REQUIRED" 234 245 default = v["flags"] == "ITEM_DEFAULT" 235 defaultvalue = defvalue(type, name, v["default_value"]) 246 defaultvalue = defvalue(type, name, v["default_value"]) 247 #print "(default:", defaultvalue, ")", 236 248 #defaultvalue = CONF2VALUE.get(v["default_value"],v["default_value"]) 237 249 if default: 238 value = defaultvalue 250 #print "default" 251 value = defaultvalue 239 252 else: 240 value = defvalue(type, name, None) 253 value = defvalue(type, name, None) 254 #print "no default, value:", value 241 255 #if type=='store_bool': 242 256 # print "Bool" … … 440 454 cf = open(filename).read() 441 455 for entry in RXP_DOT_COMMAND_ENTRY.finditer(cf): 442 #print entry.groups()443 commands[entry.group("cmdtext")]= command(entry.group("cmdtext"),456 #print entry.groups() 457 commands[entry.group("cmdtext")]= command(entry.group("cmdtext"), 444 458 entry.group("cmd"), 445 459 '', … … 477 491 daemon = 'inc' 478 492 directives(daemon, parse_conf_c(filename)) 479 480 493 481 inc = False 494 inc = False 482 495 for daemon, conf in C_CONFS: 483 496 if daemon == 'inc':
Note:
See TracChangeset
for help on using the changeset viewer.