On 11/13/2017 01:11 PM, Alec Warner wrote: > > > On Sun, Nov 12, 2017 at 6:48 AM, Zac Medico <zmed...@gentoo.org > <mailto:zmed...@gentoo.org>> wrote: > > diff --git a/pym/portage/dep/_dnf.py b/pym/portage/dep/_dnf.py > new file mode 100644 > index 000000000..503b209c2 > --- /dev/null > +++ b/pym/portage/dep/_dnf.py > @@ -0,0 +1,97 @@ > +# Copyright 2017 Gentoo Foundation > +# Distributed under the terms of the GNU General Public License v2 > + > +from __future__ import unicode_literals > + > +import itertools > + > + > +def dnf_convert(dep_struct): > + """ > + Convert dep_struct to disjunctive normal form (DNF), where > dep_struct > + is either a conjunction or disjunction of the form produced by > + use_reduce(opconvert=True). > + """ > + # Normalize input to have a top-level conjunction. > + if isinstance(dep_struct, list): > + if dep_struct and dep_struct[0] == '||': > + dep_struct = [dep_struct] > + else: > + dep_struct = [dep_struct] > + > + conjunction = [] > + disjunctions = [] > + > + for x in dep_struct: > + if isinstance (x, list): > + assert x > > > > I'm not a huge fan of asserts, but if we use them can we use them in the > expr, message form? > > assert x, "Assertion failed, wanted x in list form in dep: %s" % dep_struct > > or whatever.
Yes, I've added messages in v2. Also, I noticed that the above assertion wasn't strict enough. Fixing that allowed me to eliminate some unnecessary code. -- Thanks, Zac
signature.asc
Description: OpenPGP digital signature