|
| 1 | +import csv |
1 | 2 | import re
|
2 |
| -import requests |
3 |
| -import sys |
4 | 3 | import tarfile
|
5 | 4 | from dataclasses import dataclass
|
6 | 5 | from pathlib import Path
|
7 | 6 | from tempfile import TemporaryDirectory
|
8 | 7 |
|
| 8 | +import requests |
| 9 | + |
| 10 | + |
9 | 11 | REPO_URL = "https://github.com/conda-forge/cfep"
|
10 | 12 | REPO_ARCHIVE = "https://github.com/conda-forge/cfep/archive/main.tar.gz"
|
11 | 13 | REPO_CONTENTS = "https://api.github.com/repos/conda-forge/cfep/contents/"
|
|
14 | 16 | REPO_DIR = Path(__file__).parents[1].absolute()
|
15 | 17 | CFEP_INDEX_MD_TMPL = REPO_DIR / "docs" / "orga" / "cfep-index.md.tmpl"
|
16 | 18 | CFEP_INDEX_MD = REPO_DIR / "docs" / "orga" / "cfep-index.md"
|
| 19 | +GOVERNANCE_MD_TMPL = REPO_DIR / "docs" / "orga" / "governance.md.tmpl" |
| 20 | +GOVERNANCE_MD = REPO_DIR / "docs" / "orga" / "governance.md" |
| 21 | +CORE_CSV = REPO_DIR / "src" / "core.csv" |
| 22 | +EMERITUS_CSV = REPO_DIR / "src" / "emeritus.csv" |
17 | 23 |
|
18 | 24 |
|
19 | 25 | @dataclass
|
@@ -103,5 +109,30 @@ def write_cfep_index():
|
103 | 109 | CFEP_INDEX_MD.write_text(contents)
|
104 | 110 |
|
105 | 111 |
|
| 112 | +def _get_formatted_names(path_file): |
| 113 | + with open(path_file, "r") as csv_file: |
| 114 | + dict_csv = csv.DictReader(csv_file) |
| 115 | + sorted_csv = sorted(dict_csv, key=lambda d: d["name"]) |
| 116 | + return "\n".join( |
| 117 | + f"- [{m['name']} @{m['github_username']}]" |
| 118 | + f"(https://github.com/{m['github_username']}>)" |
| 119 | + for m in sorted_csv |
| 120 | + ) |
| 121 | + |
| 122 | + |
| 123 | +def write_core_members(): |
| 124 | + contents = GOVERNANCE_MD_TMPL.read_text() |
| 125 | + contents = contents.replace( |
| 126 | + "{{ core_members }}", |
| 127 | + _get_formatted_names(CORE_CSV) |
| 128 | + ) |
| 129 | + contents = contents.replace( |
| 130 | + "{{ emeritus_members }}", |
| 131 | + _get_formatted_names(EMERITUS_CSV) |
| 132 | + ) |
| 133 | + GOVERNANCE_MD.write_text(contents) |
| 134 | + |
| 135 | + |
106 | 136 | if __name__ == "__main__":
|
107 | 137 | write_cfep_index()
|
| 138 | + write_core_members() |
0 commit comments