def findparam(self, line):
        """Extracts a valid parameter from a line in a config file -
        or returns None.
        A valid parameter is at the start of the line (excluding whitespace)
        and either between " " or ' ' or ends with a space.
        Invalid lines print an error and the line to stout using the
        stout.out(line) method."""
        line=line.strip()
        if line=='':                            # remove blank lines
            return None
        if line[0]== '#' or line[0]== ';':      # extract comments
            return None
        if line[0] =="'" or line[0] == '"':     #    if the keyword is escaped in quotes
            test = line[1:].find(line[0])
            if  test == -1: # if it starts with a quote but there isn't a second quote in the line
                self.stout.out("Badly formed line in config file (keyword doesn't have matching quotes): \n") 
                self.stout.out(line+'\n')
                return None
            else:
                param = line[1:test+1]
                return param

        test = line.find(' ')   # if we have no quotes we must have a space to seperate 
        if test == -1:          # if there are no quotes and no space then we have no keyword-value pair
            self.stout.out('Badly formed line in config file : \n') 
            self.stout.out(line+'\n\n')
            return None
        return line[:test]
Extracts a valid parameter from a line in a config file -
        or returns None.
        A valid parameter is at the start of the line (excluding whitespace)
        and either between " " or ' ' or ends with a space.
        Invalid lines print an error and the line to stout using the
        stout.out(line) method.
recipes/Python/259175_ConfigObj__Lightweight_Config_File/recipe-259175.py