aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-header.py
blob: 67aea386bb53c8df26c9111b2918e9b7e574af09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3

import sys
import re

line_re = [
  r'^\/\/\={69}$',
  r'^\/\/ \w+',
  r'^\/\/ spdx-license-identifier: (ISC)',
  r'^\/\/ description: \w+'
]

if __name__ == '__main__':
  errors = 0

  with open(sys.argv[1]) as f:
    for i in range(len(line_re)):
      if re.search(line_re[i], f.readline()) == None:
        print(f'wrong license header: {sys.argv[1]}:{i}')
        errors += 1

  if errors != 0:
    sys.exit(1)