File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
+ import re
2
3
from collections import defaultdict
3
4
from subprocess import check_output
4
5
6
+ README_FILE = "README.md"
7
+
8
+
5
9
lines = check_output (["go" , "run" , "./cmd/chroma/main.go" , "--list" ]).decode ("utf-8" ).splitlines ()
6
10
lines = [line .strip () for line in lines if line .startswith (" " ) and not line .startswith (" " )]
7
11
lines = sorted (lines , key = lambda l : l .lower ())
11
15
for line in lines :
12
16
table [line [0 ].upper ()].append (line )
13
17
18
+ rows = []
14
19
for key , value in table .items ():
15
- print ("{} | {}" .format (key , ", " .join (value )))
20
+ rows .append ("{} | {}" .format (key , ", " .join (value )))
21
+ tbody = "\n " .join (rows )
22
+
23
+ with open (README_FILE , "r" ) as f :
24
+ content = f .read ()
25
+
26
+ with open (README_FILE , "w" ) as f :
27
+ marker = re .compile (r"(?P<start>:----: \\| --------\n).*?(?P<end>\n\n)" , re .DOTALL )
28
+ replacement = r"\g<start>%s\g<end>" % tbody
29
+ updated_content = marker .sub (replacement , content )
30
+ f .write (updated_content )
31
+
32
+ print (tbody )
You can’t perform that action at this time.
0 commit comments