aboutsummaryrefslogtreecommitdiff
path: root/scripts/maintainers.py
blob: b4111b225e1bd6c6ccb4fd82442c3a61ec21e40c (plain)
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
45
46
47
48
# This file is used to generate the list of maintainers from the maintainers.yml
# file. It is used to make sure that all the maintainers are listed in the
# README.md file.

import yaml

def main():
    # Load the maintainers.yml file
    with open('maintainers.yml', 'r') as f:
        maintainers = yaml.safe_load(f)

    # Load the README.md file
    with open('README.md', 'r') as f:
        readme = f.read()

    # Generate the list of maintainers
    maintainers_list = ""
    maintainer_images = ""
    for maintainer in maintainers:
        if not maintainer['name'] or not maintainer['github']:
            # Skip maintainers without a name or github username
            continue

        # Generate the markdown for the maintainer
        maintainers_list += "- [{}]({})".format(maintainer['name'], maintainer['github'])
        if maintainer['email']:
            maintainers_list += "<{}>".format(maintainer['email'])

        if maintainer['website']:
            maintainers_list += " - [{}]({})".format(maintainer['website'], maintainer['website'])

        # Move to next line
        maintainers_list += "\r"

        # Generate the markdown for the maintainer's image
        image_url = "https://github.com/{}.png?size=40".format(maintainer['github'])
        maintainer_images += "![{}]({}) ".format(maintainer['name'], image_url)

    # Replace "<!-- maintainers -->" in the README.md file
    readme = readme.replace("<!-- maintainers -->", "<!-- maintainers -->\r" + maintainers_list + "\r" + maintainer_images)

    # Save the README.md file
    with open('README.md', 'w') as f:
        f.write(readme)


if __name__ == '__main__':
    main()