(self, section)
Validate if a section is a valid rule
        @type section: configobj.Section
        @param section: section to validate
        @rtype Rule or None
        @return None if invalid
Validate if a section is a valid rule
Validate if a section is a valid rule
def compile_section(self, section):
        """
        Validate if a section is a valid rule
        @type section: configobj.Section
        @param section: section to validate
        @rtype Rule or None
        @return None if invalid
        """
        if section.__class__ != Section:
            # not a section, just skip
            return

        # name and path are mandatory
        keys = section.keys()
        for key in ('name', 'path'):
            if key not in keys:
                self.log.warning("section %s miss key '%s' ignore", key,
                                 section.name)
                return

        # just warn if invalid key in section
        for key in keys:
            if key not in self.VALID_RULES_KEYS:
                self.log.warning("invalid key %s in section %s",
                                 key, section.name)

        # need at least a min or a max
        if 'min' not in keys and 'max' not in keys:
            self.log.warning("either 'min' or 'max' is defined in %s",
                             section.name)
            return

        # add rule to the list
        kwargs = {
            'name': section['name'],
            'path': section['path']
        }
        for argument in ('min', 'max'):
            try:
                kwargs[argument] = section[argument]
            except KeyError:
                pass

        # init rule
        try:
            return Rule(**kwargs)
        except InvalidRule as err:
            self.log.error(str(err))
def compile_section ( self , section ) : if section . __class__ != Section : # not a section, just skip return # name and path are mandatory keys = section . keys ( ) for key in ( 'name' , 'path' ) : if key not in keys : self . log . warning ( "section %s miss key '%s' ignore" , key , section . name ) return # just warn if invalid key in section for key in keys : if key not in self . VALID_RULES_KEYS : self . log . warning ( "invalid key %s in section %s" , key , section . name ) # need at least a min or a max if 'min' not in keys and 'max' not in keys : self . log . warning ( "either 'min' or 'max' is defined in %s" , section . name ) return # add rule to the list kwargs = { 'name' : section [ 'name' ] , 'path' : section [ 'path' ] } for argument in ( 'min' , 'max' ) : try : kwargs [ argument ] = section [ argument ] except KeyError : pass # init rule try : return Rule ( * * kwargs ) except InvalidRule as err : self . log . error ( str ( err ) )