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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux