Skip to content

Commit ca26ed8

Browse files
authored
Render some community pages from conda-forge/governance (#2517)
* Render from conda-forge/governance * address warnings * Not needed anymore
1 parent 1f912e4 commit ca26ed8

File tree

9 files changed

+44
-452
lines changed

9 files changed

+44
-452
lines changed

.ci_scripts/render_templated_content.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import csv
2+
import io
23
import re
34
import tarfile
45
from dataclasses import dataclass
@@ -8,18 +9,19 @@
89
import requests
910

1011

11-
REPO_URL = "https://github.com/conda-forge/cfep"
12-
REPO_ARCHIVE = "https://github.com/conda-forge/cfep/archive/main.tar.gz"
13-
REPO_CONTENTS = "https://api.github.com/repos/conda-forge/cfep/contents/"
14-
TITLE_PATTERN = "<td>\s*Title\s*</td><td>\s*(.*)\s*</td>"
15-
STATUS_PATTERN = "<td>\s*Status\s*</td><td>\s*(.*)\s*</td>"
12+
CFEP_REPO_URL = "https://github.com/conda-forge/cfep"
13+
CFEP_REPO_ARCHIVE = "https://github.com/conda-forge/cfep/archive/main.tar.gz"
14+
CFEP_REPO_CONTENTS = "https://api.github.com/repos/conda-forge/cfep/contents/"
15+
GOVERNANCE_REPO_URL = "https://github.com/conda-forge/governance"
16+
TITLE_PATTERN = r"<td>\s*Title\s*</td><td>\s*(.*)\s*</td>"
17+
STATUS_PATTERN = r"<td>\s*Status\s*</td><td>\s*(.*)\s*</td>"
1618
REPO_DIR = Path(__file__).parents[1].absolute()
1719
CFEP_INDEX_MD_TMPL = REPO_DIR / "community" / "cfep-index.md.tmpl"
1820
CFEP_INDEX_MD = REPO_DIR / "community" / "cfep-index.md"
1921
GOVERNANCE_MD_TMPL = REPO_DIR / "community" / "governance.md.tmpl"
2022
GOVERNANCE_MD = REPO_DIR / "community" / "governance.md"
21-
CORE_CSV = REPO_DIR / "src" / "core.csv"
22-
EMERITUS_CSV = REPO_DIR / "src" / "emeritus.csv"
23+
CODE_OF_CONDUCT_MD_TMPL = REPO_DIR / "community" / "code-of-conduct.md.tmpl"
24+
CODE_OF_CONDUCT_MD = REPO_DIR / "community" / "code-of-conduct.md"
2325

2426

2527
@dataclass
@@ -46,7 +48,7 @@ def md_link(self) -> str:
4648
def get_cfeps_from_gh_api():
4749
"""Generator that returns all CFEPs from GitHub repo"""
4850
response = requests.get(
49-
REPO_CONTENTS, headers={"Accept": "application/vnd.github.v3+json"}
51+
CFEP_REPO_CONTENTS, headers={"Accept": "application/vnd.github.v3+json"}
5052
)
5153
response.raise_for_status()
5254
for content in response.json():
@@ -70,7 +72,7 @@ def get_cfeps_from_gh_api():
7072

7173
def get_cfeps():
7274
"""Return a generator of CFEPs, by traversing the contents of the repo archive"""
73-
r = requests.get(REPO_ARCHIVE, stream=True)
75+
r = requests.get(CFEP_REPO_ARCHIVE, stream=True)
7476
r.raise_for_status()
7577
with TemporaryDirectory() as tmp:
7678
# Write the tarball to a temporary directory
@@ -86,7 +88,7 @@ def get_cfeps():
8688
# Traverse the extracted directory and return all CFEPs
8789
for cfep in sorted(extracted_dir.rglob("cfep-*.md")):
8890
name = cfep.name
89-
url = f"{REPO_URL}/blob/main/{name}"
91+
url = f"{CFEP_REPO_URL}/blob/main/{name}"
9092
if name == "cfep-00.md":
9193
# Hardcode title and status for CFEP-00
9294
yield Cfep(name, "CFEP Template", "Proposed", url)
@@ -106,26 +108,43 @@ def write_cfep_index():
106108
CFEP_INDEX_MD.write_text(contents)
107109

108110

109-
def _get_formatted_names(path_file):
110-
with open(path_file, "r") as csv_file:
111-
dict_csv = csv.DictReader(csv_file)
112-
sorted_csv = sorted(dict_csv, key=lambda d: d["name"])
111+
def _get_formatted_names(csv_contents):
112+
memfile = io.StringIO(csv_contents)
113+
dict_csv = csv.DictReader(memfile)
114+
sorted_csv = sorted(dict_csv, key=lambda d: d["name"])
113115
return "\n".join(
114116
f"- [{m['name']} @{m['github_username']}]"
115117
f"(https://github.com/{m['github_username']})"
116118
for m in sorted_csv
117119
)
118120

119121

120-
def write_core_members():
122+
def write_code_of_conduct():
123+
r = requests.get(f"{GOVERNANCE_REPO_URL}/raw/main/CODE_OF_CONDUCT.md")
124+
r.raise_for_status()
125+
contents = CODE_OF_CONDUCT_MD_TMPL.read_text()
126+
contents += r.text
127+
CODE_OF_CONDUCT_MD.write_text(contents)
128+
129+
130+
def write_governance():
131+
readme = requests.get(f"{GOVERNANCE_REPO_URL}/raw/main/README.md")
132+
readme.raise_for_status()
133+
core = requests.get(f"{GOVERNANCE_REPO_URL}/raw/main/teams/core.csv")
134+
core.raise_for_status()
135+
emeritus = requests.get(f"{GOVERNANCE_REPO_URL}/raw/main/teams/emeritus.csv")
136+
emeritus.raise_for_status()
121137
contents = GOVERNANCE_MD_TMPL.read_text()
122-
contents = contents.replace("{{ core_members }}", _get_formatted_names(CORE_CSV))
138+
contents += readme.text
139+
contents = contents.replace("{{ core_members }}", _get_formatted_names(core.text))
123140
contents = contents.replace(
124-
"{{ emeritus_members }}", _get_formatted_names(EMERITUS_CSV)
141+
"{{ emeritus_members }}", _get_formatted_names(emeritus.text)
125142
)
143+
contents = contents.replace("(./CODE_OF_CONDUCT.md)", "(./code-of-conduct.md)")
126144
GOVERNANCE_MD.write_text(contents)
127145

128146

129147
if __name__ == "__main__":
130148
write_cfep_index()
131-
write_core_members()
149+
write_governance()
150+
write_code_of_conduct()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ sphinx/newsfeed/demo/_build
3535
/static/schema/conda-forge.schema.json
3636
/community/cfep-index.md
3737
/community/governance.md
38+
/community/code-of-conduct.md
3839

3940
# Generated files
4041
.docusaurus

.pre-commit-config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,5 @@ repos:
1818
rev: v0.11.8
1919
hooks:
2020
- id: ruff-format
21-
- repo: local
22-
hooks:
23-
- id: sort-csv
24-
name: Sort core and emeritus lists
25-
entry: scripts/sort_csv.py
26-
language: python
27-
types: [text]
28-
files: src/(core|emeritus)\.csv
2921
ci:
3022
autofix_prs: false

community/code-of-conduct.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

community/code-of-conduct.md.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
custom_edit_url: 'https://github.com/conda-forge/governance/blob/main/CODE_OF_CONDUCT.md'
3+
---

0 commit comments

Comments
 (0)