File: droppable-diff.py

package info (click to toggle)
botch 0.24-6.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,084,624 kB
  • sloc: xml: 11,924,892; ml: 4,489; python: 3,890; sh: 1,268; makefile: 334
file content (44 lines) | stat: -rwxr-xr-x 1,374 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3

from __future__ import print_function
import sys

sys.path.append("/usr/share/botch")
from util import read_reduced_deps

if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(
        description=(
            "Display the difference between two files with "
            + "droppable build dependencies"
        )
    )
    parser.add_argument("droppable1", type=read_reduced_deps, help="file 1")
    parser.add_argument("droppable2", type=read_reduced_deps, help="file 2")
    parser.add_argument("-v", "--verbose", action="store_true", help="be verbose")
    args = parser.parse_args()

    only_in_1 = set(args.droppable1.keys()) - set(args.droppable2.keys())
    only_in_2 = set(args.droppable2.keys()) - set(args.droppable1.keys())
    in_both = set(args.droppable1.keys()) & set(args.droppable2.keys())

    for srcpkg in in_both:
        d1 = set(args.droppable1[srcpkg])
        d2 = set(args.droppable2[srcpkg])
        o_i_1 = d1 - d2
        o_i_2 = d2 - d1
        if not o_i_1 and not o_i_2:
            continue
        print(srcpkg)
        if o_i_1:
            print("< %s" % (" ".join(o_i_1)))
        if o_i_2:
            print("> %s" % (" ".join(o_i_2)))

    if only_in_1:
        print("only in <: %s", ",".join(only_in_1))

    if only_in_2:
        print("only in >: %s", ",".join(only_in_2))