Add missing return in gori_compute::logical_combine
[official-gcc.git] / contrib / check-MAINTAINERS.py
blob0378d2914328e051e6ebfc7e3240cc383734761e
1 #!/usr/bin/env python3
3 # Copyright (C) 2022-2023 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
12 # GCC is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING. If not, write to
19 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 # Boston, MA 02110-1301, USA.
22 # Check that names in the file are sorted
23 # alphabetically by surname.
25 import locale
26 import sys
27 from difflib import ndiff
28 from itertools import dropwhile, takewhile
30 import unidecode
32 locale.setlocale(locale.LC_ALL, 'en_US.utf8')
34 exit_code = 0
36 if len(sys.argv) != 2:
37 print('Usage: ./check-MAINTAINERS.py path-to/MAINTAINERS')
38 sys.exit(1)
41 def sort_by_surname(line):
42 name = line.split('\t')[0]
43 parts = name.split()
44 surname = parts[-1]
46 # Special-case some names
47 if name == 'Stefan Schulze Frielinghaus':
48 surname = parts[1]
49 elif name == 'Kris Van Hees':
50 surname = parts[1]
51 elif surname == "d'Humieres":
52 surname = 'Humieres'
54 # Remove accents
55 return (unidecode.unidecode(surname), line)
58 def has_tab(line):
59 return '\t' in line
62 def is_empty(line):
63 return line
66 def check_group(name, lines):
67 global exit_code
69 for line in lines:
70 if line.startswith(' '):
71 print(f'Line should not start with space: "{line}"')
72 exit_code = 2
74 lines = [line + '\n' for line in lines]
75 sorted_lines = sorted(lines, key=sort_by_surname)
76 if lines != sorted_lines:
77 exit_code = 1
78 diff = ndiff(lines, sorted_lines)
79 print(f'Wrong order for {name}:\n')
80 print(''.join(diff))
81 else:
82 print(f'{name} are fine!')
85 lines = open(sys.argv[1]).read().splitlines()
87 needle = 'Global Reviewers'
88 lines = list(dropwhile(lambda x: x.strip() != needle, lines))
89 lines = lines[2:]
91 chunk = list(takewhile(is_empty, lines))
92 check_group(needle, chunk)
94 needle = 'Write After Approval'
95 lines = list(dropwhile(lambda x: needle not in x, lines))
96 lines = lines[2:]
98 chunk = list(takewhile(is_empty, lines))
99 check_group(needle, chunk)
101 needle = 'Bug database only accounts'
102 lines = list(dropwhile(lambda x: needle not in x, lines))
103 lines = lines[2:]
105 chunk = list(takewhile(is_empty, lines))
106 check_group(needle, chunk)
108 needle = 'Contributing under the DCO'
109 lines = list(dropwhile(lambda x: needle not in x, lines))[1:]
110 lines = list(dropwhile(lambda x: not has_tab(x), lines))
111 check_group(needle, lines)
113 sys.exit(exit_code)