tests: replace pycodestyle with black
[vpp.git] / extras / scripts / list_api_changes.py
1 #!/usr/bin/env python3
2 from __future__ import print_function
3 import fnmatch
4 import os
5 import subprocess
6
7 starttag = "v19.08-rc0"
8 endtag = "HEAD"
9 emit_md = True
10 apifiles = []
11
12 for root, dirnames, filenames in os.walk("."):
13     for filename in fnmatch.filter(filenames, "*.api"):
14         apifiles.append(os.path.join(root, filename))
15
16 for f in apifiles:
17     commits = subprocess.check_output(
18         ["git", "log", "--oneline", starttag + ".." + endtag, f]
19     )
20     if commits:
21         if f[0:2] == "./":
22             f = f[2:]
23         if emit_md:
24             print("| @c %s ||" % f)
25             print("| ------- | ------- |")
26             for line in commits.splitlines():
27                 parts = line.strip().split()
28                 commit = parts[0]
29                 message = b" ".join(parts[1:]).decode().replace("|", r"\|")
30                 print(
31                     "| [%s](https://gerrit.fd.io/r/gitweb?"
32                     "p=vpp.git;a=commit;h=%s) | %s |" % (commit, commit, message)
33                 )
34             print()
35         else:
36             print(f)
37             print(commits)