(self, cf_params)
Change the configuration parameters supplied in cf_params
Change the configuration parameters supplied in cf_params
Change the configuration parameters supplied in cf_params
def modify(self, cf_params):
        """Change the configuration parameters supplied in cf_params"""

        for (param, value) in cf_params.iteritems():
            r_active = re.compile("^\s*%s\s*=\s*([^\s#]*).*$" % param, re.M)
            r_disabled = re.compile("^\s*#\s*%s\s*=.*$" % param, re.M)

            cf_full = "%s = '%s'" % (param, value)

            m = r_active.search(self.cf_buf)
            if m:
                old_val = m.group(1)
                self.log.debug("found parameter %s with value %r", param, old_val)
                self.cf_buf = "%s%s%s" % (self.cf_buf[:m.start()], cf_full, self.cf_buf[m.end():])
            else:
                m = r_disabled.search(self.cf_buf)
                if m:
                    self.log.debug("found disabled parameter %s", param)
                    self.cf_buf = "%s\n%s%s" % (self.cf_buf[:m.end()], cf_full, self.cf_buf[m.end():])
                else:
                    # not found, append to the end
                    self.log.debug("found no value")
                    self.cf_buf = "%s\n%s\n\n" % (self.cf_buf, cf_full)
def modify ( self , cf_params ) : for ( param , value ) in cf_params . iteritems ( ) : r_active = re . compile ( "^\s*%s\s*=\s*([^\s#]*).*$" % param , re . M ) r_disabled = re . compile ( "^\s*#\s*%s\s*=.*$" % param , re . M ) cf_full = "%s = '%s'" % ( param , value ) m = r_active . search ( self . cf_buf ) if m : old_val = m . group ( 1 ) self . log . debug ( "found parameter %s with value %r" , param , old_val ) self . cf_buf = "%s%s%s" % ( self . cf_buf [ : m . start ( ) ] , cf_full , self . cf_buf [ m . end ( ) : ] ) else : m = r_disabled . search ( self . cf_buf ) if m : self . log . debug ( "found disabled parameter %s" , param ) self . cf_buf = "%s\n%s%s" % ( self . cf_buf [ : m . end ( ) ] , cf_full , self . cf_buf [ m . end ( ) : ] ) else : # not found, append to the end self . log . debug ( "found no value" ) self . cf_buf = "%s\n%s\n\n" % ( self . cf_buf , cf_full )