python-pathvalidate: bump version to 0.14.1
[buildroot-gz.git] / support / scripts / get-developers
blob40ed08ffe1e7db5d88af839402772c555634f90c
1 #!/usr/bin/env python
3 import argparse
4 import getdeveloperlib
6 def parse_args():
7 parser = argparse.ArgumentParser()
8 parser.add_argument('patches', metavar='P', type=argparse.FileType('r'), nargs='*',
9 help='list of patches (use - to read patches from stdin)')
10 parser.add_argument('-a', dest='architecture', action='store',
11 help='find developers in charge of this architecture')
12 parser.add_argument('-p', dest='package', action='store',
13 help='find developers in charge of this package')
14 parser.add_argument('-c', dest='check', action='store_const',
15 const=True, help='list files not handled by any developer')
16 return parser.parse_args()
18 def __main__():
19 devs = getdeveloperlib.parse_developers()
20 if devs is None:
21 sys.exit(1)
22 args = parse_args()
24 # Check that only one action is given
25 action = 0
26 if args.architecture is not None:
27 action += 1
28 if args.package is not None:
29 action += 1
30 if args.check:
31 action += 1
32 if len(args.patches) != 0:
33 action += 1
34 if action > 1:
35 print("Cannot do more than one action")
36 return
37 if action == 0:
38 print("No action specified")
39 return
41 # Handle the check action
42 if args.check:
43 files = getdeveloperlib.check_developers(devs)
44 for f in files:
45 print(f)
47 # Handle the architecture action
48 if args.architecture is not None:
49 for dev in devs:
50 if args.architecture in dev.architectures:
51 print(dev.name)
52 return
54 # Handle the package action
55 if args.package is not None:
56 for dev in devs:
57 if args.package in dev.packages:
58 print(dev.name)
59 return
61 # Handle the patches action
62 if len(args.patches) != 0:
63 (files, infras) = getdeveloperlib.analyze_patches(args.patches)
64 matching_devs = set()
65 for dev in devs:
66 # See if we have developers matching by package name
67 for f in files:
68 if dev.hasfile(f):
69 matching_devs.add(dev.name)
70 # See if we have developers matching by package infra
71 for i in infras:
72 if i in dev.infras:
73 matching_devs.add(dev.name)
75 result = "--to buildroot@buildroot.org"
76 for dev in matching_devs:
77 result += " --cc \"%s\"" % dev
79 if result != "":
80 print("git send-email %s" % result)
82 __main__()