(self, main_section, filename, sane_config = 1, user_defs = {}, override = {}, ignore_defs = False)
Initialize Config and read from file.

        @param sane_config:  chooses between ConfigParser/SafeConfigParser.
Initialize Config and read from file.
Initialize Config and read from file .
def __init__(self, main_section, filename, sane_config = 1, user_defs = {}, override = {}, ignore_defs = False):
        """Initialize Config and read from file.

        @param sane_config:  chooses between ConfigParser/SafeConfigParser.
        """
        # use config file name as default job_name
        if filename:
            job_name = os.path.splitext(os.path.basename(filename))[0]
        else:
            job_name = main_section

        # initialize defaults, make them usable in config file
        if ignore_defs:
            self.defs = {}
        else:
            self.defs = {
                'job_name': job_name,
                'service_name': main_section,
                'host_name': socket.gethostname(),
            }
            if filename:
                self.defs['config_dir'] = os.path.dirname(filename)
                self.defs['config_file'] = filename
            self.defs.update(user_defs)

        self.main_section = main_section
        self.filename = filename
        self.sane_config = sane_config
        self.override = override
        if sane_config:
            self.cf = ConfigParser.SafeConfigParser()
        else:
            self.cf = ConfigParser.ConfigParser()

        if filename is None:
            self.cf.add_section(main_section)
        elif not os.path.isfile(filename):
            raise Exception('Config file not found: '+filename)

        self.reload()
def __init__ ( self , main_section , filename , sane_config = 1 , user_defs = { } , override = { } , ignore_defs = False ) : # use config file name as default job_name if filename : job_name = os . path . splitext ( os . path . basename ( filename ) ) [ 0 ] else : job_name = main_section # initialize defaults, make them usable in config file if ignore_defs : self . defs = { } else : self . defs = { 'job_name' : job_name , 'service_name' : main_section , 'host_name' : socket . gethostname ( ) , } if filename : self . defs [ 'config_dir' ] = os . path . dirname ( filename ) self . defs [ 'config_file' ] = filename self . defs . update ( user_defs ) self . main_section = main_section self . filename = filename self . sane_config = sane_config self . override = override if sane_config : self . cf = ConfigParser . SafeConfigParser ( ) else : self . cf = ConfigParser . ConfigParser ( ) if filename is None : self . cf . add_section ( main_section ) elif not os . path . isfile ( filename ) : raise Exception ( 'Config file not found: ' + filename ) self . reload ( )