[libvirt-ci PATCH v2 06/13] lcitool: Introduce methods to load and validate the YAML config

Erik Skultety eskultet at redhat.com
Thu May 14 07:32:26 UTC 2020


On Wed, May 13, 2020 at 06:48:26PM +0200, Andrea Bolognani wrote:
> On Tue, 2020-05-12 at 16:42 +0200, Erik Skultety wrote:
> > +    def _validate_section(self, config, section, mandatory_keys):
> > +        # remove keys we don't recognize
> > +        self._remove_unknown_keys(config[section], self.values[section].keys())
> > +
> > +        # check that the mandatory keys are present and non-empty
> > +        for key in mandatory_keys:
> > +            if config.get(section).get(key, None) is None:
> 
> Isn't
> 
>   foo.get("bar")
> 
> defined as returning None if the "bar" key is not defined for the
> dictionary foo? Basically, I think you could write this as
> 
>   if config.get(section).get(key) is None:

Correct, I was just being explicit, it might not be clear at first glance that
None is the default return value, but I agree that what you suggest is the
Pythonic way, so I'll happily change it.

-- 
Erik Skultety




More information about the libvir-list mailing list