File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 5
5
from http .client import HTTPSConnection
6
6
from io import StringIO
7
7
from json import load
8
+ from os import PathLike
9
+ from pathlib import Path
8
10
9
11
10
12
INDEX_HBS_DOMAIN = "api.github.com"
49
51
"""
50
52
51
53
52
- def main () :
54
+ def update_theme ( target : PathLike ) -> None :
53
55
with closing (HTTPSConnection (INDEX_HBS_DOMAIN , INDEX_HBS_PORT )) as conn :
54
56
conn .request (INDEX_HBS_PROTO , INDEX_HBS_PATH , None , INDEX_HBS_HEADERS )
55
57
res = conn .getresponse ()
@@ -64,7 +66,7 @@ def main():
64
66
output_f = StringIO ()
65
67
66
68
_ , revision = data ["git_url" ].rsplit ("/" , 1 )
67
- print ("{{!-- Source revision:" , revision , "--}}" , file = output_f )
69
+ print ("Source revision:" , revision )
68
70
69
71
state = "before-sidebar"
70
72
for line in input_f :
@@ -93,10 +95,13 @@ def main():
93
95
state = "after-sidebar"
94
96
output_f .write (line )
95
97
98
+ if state != "after-sidebar" :
99
+ raise Exception (f"state={ state !r} " )
100
+
96
101
output_f .seek (0 , 0 )
97
- with open ("./theme/index.hbs" , "wt" ) as f :
102
+ with open (target , "wt" ) as f :
98
103
print (output_f .read (), end = "" , file = f )
99
104
100
105
101
106
if __name__ == "__main__" :
102
- main ( )
107
+ update_theme ( Path ( __file__ ). absolute (). parent / "theme" / "index.hbs" )
You can’t perform that action at this time.
0 commit comments