-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathpre-process.py
More file actions
25 lines (19 loc) · 827 Bytes
/
pre-process.py
File metadata and controls
25 lines (19 loc) · 827 Bytes
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
import yaml
with open("AUTHORS.md", "r") as f:
authors = f.read().replace("\n", " ").strip(" ")
with open("metadata.yml", "r") as f:
meta = yaml.load(f, Loader=yaml.SafeLoader)
# populate _config with tutorial-specific metadata
with open("astropy-tutorials/_config.yml") as f:
cfg = yaml.load(f, Loader=yaml.SafeLoader)
cfg["title"] = meta["title"]
cfg["author"] = authors
# cfg["repository"]["url"] = f"https://github.com/astropy-learn/{meta['source']}"
cfg["sphinx"]["config"]["html_theme_options"]["repository_url"] = (
f"https://github.com/astropy-learn/{meta['source']}"
)
# save populated '_config.yml' in the target repo
with open("_config.yml", "w") as f:
cfg = yaml.dump(cfg, stream=f, default_flow_style=False, sort_keys=False)
# for use by subsequent github actions job
print(meta["slug"])