forked from PlasmaPy/plasmapy.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull_from_github.py
executable file
·39 lines (35 loc) · 1.2 KB
/
pull_from_github.py
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
#!/usr/bin/env python
import requests as re
OUTPUT_DIR = "web/pages/"
BASE_URL = "https://raw.githubusercontent.com/PlasmaPy/PlasmaPy/master/"
WEB_BASE_URL = "https://raw.githubusercontent.com/PlasmaPy/plasmapy.github.io/src/"
PAGES = [
{"filename": OUTPUT_DIR + "conduct.md",
"url": BASE_URL + "CODE_OF_CONDUCT.md",
"metadata": {
"title": "Code of conduct",
"slug": "conduct"}},
{"filename": OUTPUT_DIR + "contribute.md",
"url": BASE_URL + "CONTRIBUTING.md",
"metadata": {
"title": "Contribute to PlasmaPy",
"slug": "contribute"}},
{"filename": OUTPUT_DIR + "license.md",
"url": WEB_BASE_URL + "LICENSE.md",
"metadata": {
"title": "License",
"slug": "license"}},
{"filename": OUTPUT_DIR + "vision.md",
"url": BASE_URL + "vision_statement.md",
"metadata": {
"title": "Vision statement",
"slug": "vision"}},
]
for page in PAGES:
content = ""
for field, tag in page["metadata"].items():
content += "{}: {}\n".format(field, tag)
content += "\n"
content += re.get(page["url"]).content.decode("utf-8")
with open(page["filename"], "w+") as f:
f.write(content)