comparison multimerge.py @ 119:f671602635b7

Rename some objects and variables.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 18 Oct 2016 14:39:59 +0300
parents 591cc558bbcd
children 1f7967aa0133
comparison
equal deleted inserted replaced
118:03e0063cb15c 119:f671602635b7
299 if name in self.m_data: 299 if name in self.m_data:
300 return self.m_data[name] 300 return self.m_data[name]
301 else: 301 else:
302 return None 302 return None
303 303
304 def mread(self, cfgparser, sect): 304 def mread(self, cfg_parser, sect):
305 for name in self.m_settable: 305 for name in self.m_settable:
306 if cfgparser.has_option(sect, name): 306 if cfg_parser.has_option(sect, name):
307 value = cfgparser.get(sect, name) 307 value = cfg_parser.get(sect, name)
308 self.mset(name, value) 308 self.mset(name, value)
309 gcm_debug(4, u"{0} -> '{1}' == {2}".format(name, value, self.mget(name))) 309 gcm_debug(4, u"{0} -> '{1}' == {2}".format(name, value, self.mget(name)))
310 310
311 def is_str(self, mvalue): 311 def is_str(self, mvalue):
312 return isinstance(mvalue, basestring) 312 return isinstance(mvalue, basestring)
397 397
398 gcm_bench_start = time.time() 398 gcm_bench_start = time.time()
399 399
400 400
401 ## Settings 401 ## Settings
402 cfg_section = "gcm"
402 cfg = GCMSettings() 403 cfg = GCMSettings()
403 404
404 cfg.mdef("debug", True, cfg.is_bool, cfg.trans_bool, False) 405 cfg.mdef("debug", True, cfg.is_bool, cfg.trans_bool, False)
405 406
406 cfg.mdef("email_ok", False, None, None, False) 407 cfg.mdef("email_ok", False, None, None, False)
443 444
444 445
445 ## Read, parse and validate configuration file 446 ## Read, parse and validate configuration file
446 gcm_debug(3, u"Reading configuration from '{0}'.".format(sys.argv[1])) 447 gcm_debug(3, u"Reading configuration from '{0}'.".format(sys.argv[1]))
447 try: 448 try:
448 cfgparser = ConfigParser.RawConfigParser() 449 cfg_parser = ConfigParser.RawConfigParser()
449 cfgparser.readfp(codecs.open(sys.argv[1], "r", "UTF-8")) 450 cfg_parser.readfp(codecs.open(sys.argv[1], "r", "UTF-8"))
450 except Exception as e: 451 except Exception as e:
451 gcm_fatal(u"Failed to read configuration file '{0}': {1}".format(sys.argv[1], str(e))) 452 gcm_fatal(u"Failed to read configuration file '{0}': {1}".format(sys.argv[1], str(e)))
452 453
453 # Check that the required section exists 454 # Check that the required section exists
454 section = "gcm" 455 if not cfg_parser.has_section(cfg_section):
455 if not cfgparser.has_section(section): 456 gcm_fatal(u"Invalid configuration, missing '{0}' section.".format(cfg_section))
456 gcm_fatal(u"Invalid configuration, missing '{0}' section.".format(section))
457 457
458 # Debug setting is a special case, we need to get it 458 # Debug setting is a special case, we need to get it
459 # set before everything else, so do it here .. 459 # set before everything else, so do it here ..
460 if cfgparser.has_option(section, "debug"): 460 if cfg_parser.has_option(cfg_section, "debug"):
461 cfg.mset("debug", cfgparser.get(section, "debug")) 461 cfg.mset("debug", cfg_parser.get(cfg_section, "debug"))
462 462
463 # Parse the settings and validate 463 # Parse the settings and validate
464 cfg.mread(cfgparser, section) 464 cfg.mread(cfg_parser, cfg_section)
465 465
466 466
467 ## Validate settings 467 ## Validate settings
468 if cfg.email != "off": 468 if cfg.email != "off":
469 if cfg.email_subject == None or len(cfg.email_subject) == 0: 469 if cfg.email_subject == None or len(cfg.email_subject) == 0: