Updating python-debian support for build profiles

Stuart Prescott stuart at debian.org
Thu Sep 4 14:46:28 UTC 2014


Hi John,

> > +        def pp_restrictions(restrictions):
> > +            s = []
> > +            for r in restrictions:
> > +                s.append('%s%s.%s' % (
> > +                            '' if r.enabled else '!',
> > +                            r.namespace,
> > +                            r.label
> > +                        )
> > +                    )
> > +            return '<%s>' % ' '.join(s)
> > +
> > 
> >          def pp_atomic_dep(dep):
> >              s = dep['name']
> 
> >              if dep.get('version') is not None:
> Optional, while you're here, might make sense to either:
>   - Use the more idiomatic form: 'version' not in dep
>   - Or save the result of dep.get('version') instead of looking it up
>     twice.

There are cases where the dep['version'] exists but is None and the subsequent 
code needs protecting from that None, so it would be 

-              if dep.get('version') is not None:
+             if 'version' in dep and dep['version']:

It gets rid of an ugly looking ".get()" but is it really an improvement?


> > +                                [(False, 'profile', 'stage1')],
> 
> Weird, these are equal even though one is a raw tuple and one is a
> namedtuple type?

yeah... I don't know what sort of comparison assertEqual is doing here -- I 
assume that it just gets passed to the tuple tester.

cheers
Stuart

-- 
Stuart Prescott    http://www.nanonanonano.net/   stuart at nanonanonano.net
Debian Developer   http://www.debian.org/         stuart at debian.org
GPG fingerprint    90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7



More information about the pkg-python-debian-maint mailing list