-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmkreadme.py
More file actions
27 lines (22 loc) · 737 Bytes
/
mkreadme.py
File metadata and controls
27 lines (22 loc) · 737 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
26
27
import glob
from pathlib import Path
import re
from random import shuffle
readmes = glob.glob("*/README.md")
shuffle(readmes)
groups = {}
for r in readmes:
lang = r.split('-')[0]
if lang == 'php8': lang = 'php'
if not lang in groups: groups[lang] = ""
text = Path(r).read_text()
match = re.search(r'#(.*)',text)
if not match or not '?' in match.group(1):
print("This post does not contain question mark in the heading: "+r)
continue
groups[lang] += "### "+match.group(1)+"\n[Veja a resposta]("+r+") \n"
result = "# Questões para os amantes de programação\n"
for lang in groups:
result += "## Questões de "+lang+"\n"
result += groups[lang]
Path("README.md").write_text(result)