1 |
On 11/13/2017 01:11 PM, Alec Warner wrote: |
2 |
> |
3 |
> |
4 |
> On Sun, Nov 12, 2017 at 6:48 AM, Zac Medico <zmedico@g.o |
5 |
> <mailto:zmedico@g.o>> wrote: |
6 |
> |
7 |
> diff --git a/pym/portage/dep/_dnf.py b/pym/portage/dep/_dnf.py |
8 |
> new file mode 100644 |
9 |
> index 000000000..503b209c2 |
10 |
> --- /dev/null |
11 |
> +++ b/pym/portage/dep/_dnf.py |
12 |
> @@ -0,0 +1,97 @@ |
13 |
> +# Copyright 2017 Gentoo Foundation |
14 |
> +# Distributed under the terms of the GNU General Public License v2 |
15 |
> + |
16 |
> +from __future__ import unicode_literals |
17 |
> + |
18 |
> +import itertools |
19 |
> + |
20 |
> + |
21 |
> +def dnf_convert(dep_struct): |
22 |
> + """ |
23 |
> + Convert dep_struct to disjunctive normal form (DNF), where |
24 |
> dep_struct |
25 |
> + is either a conjunction or disjunction of the form produced by |
26 |
> + use_reduce(opconvert=True). |
27 |
> + """ |
28 |
> + # Normalize input to have a top-level conjunction. |
29 |
> + if isinstance(dep_struct, list): |
30 |
> + if dep_struct and dep_struct[0] == '||': |
31 |
> + dep_struct = [dep_struct] |
32 |
> + else: |
33 |
> + dep_struct = [dep_struct] |
34 |
> + |
35 |
> + conjunction = [] |
36 |
> + disjunctions = [] |
37 |
> + |
38 |
> + for x in dep_struct: |
39 |
> + if isinstance (x, list): |
40 |
> + assert x |
41 |
> |
42 |
> |
43 |
> |
44 |
> I'm not a huge fan of asserts, but if we use them can we use them in the |
45 |
> expr, message form? |
46 |
> |
47 |
> assert x, "Assertion failed, wanted x in list form in dep: %s" % dep_struct |
48 |
> |
49 |
> or whatever. |
50 |
|
51 |
Yes, I've added messages in v2. Also, I noticed that the above assertion |
52 |
wasn't strict enough. Fixing that allowed me to eliminate some |
53 |
unnecessary code. |
54 |
-- |
55 |
Thanks, |
56 |
Zac |