Skip to content

Commit 21bd387

Browse files
committed
If index.json is not available, support HTTP URL
1 parent 9242cb7 commit 21bd387

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

generate_metadata.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# "gitpython",
55
# "potodo",
66
# "jinja2",
7-
# "requests",
87
# "docutils",
98
# "sphinx",
109
# "python-docs-theme",
@@ -19,11 +18,13 @@
1918
from datetime import datetime, timezone
2019
from json import loads
2120
from pathlib import Path
21+
from sys import argv
2222
from tempfile import TemporaryDirectory
2323

2424
import dacite
2525
from git import Repo
2626
from jinja2 import Template
27+
from urllib3 import request
2728

2829
import build_warnings
2930
from completion import branches_from_devguide
@@ -77,10 +78,13 @@ def get_language_repo_and_completion(
7778
logging.basicConfig(level=logging.INFO)
7879
logging.info(f'starting at {generation_time}')
7980
template = Template(Path('metadata.html.jinja').read_text())
81+
if (index_path := Path('index.json')).exists():
82+
index_json = loads(Path('index.json').read_text())
83+
else:
84+
index_json = request('GET', argv[1]).json()
8085

8186
completion_progress = [
82-
dacite.from_dict(LanguageProjectData, project)
83-
for project in loads(Path('index.json').read_text())
87+
dacite.from_dict(LanguageProjectData, project) for project in index_json
8488
]
8589

8690
output = template.render(

0 commit comments

Comments
 (0)