-
Notifications
You must be signed in to change notification settings - Fork 108
/
yaml2md.py
executable file
·42 lines (35 loc) · 1023 Bytes
/
yaml2md.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
40
41
42
#!/usr/bin/env python3
import yaml
# tuples:
# - nice
# - chapter
# - name
# - links
L = []
def code(url):
for c in ":/.":
url = url.replace(c, " ")
for w in url.split():
if w not in ["http", "www", "acm", "https", "code", "google", "com", "uva", "informatik", "cs"]:
return w
return "?"
for item in yaml.load(open("problems.yaml").read()):
if 'broken' in item:
continue
if 'order' in item:
order = item['order'] - 1
else:
order = 3
chapter = item['chapter']
name = item['name']
links = item['links']
L.append((order, chapter, name, links))
L.sort(key = lambda t: (t[1].lower(),t[2].lower()))
cat = [':fish:', ':dolphin:', ':tropical_fish:', ':whale2:']
print("section | order | problem | link\n--- | --- | --- | ---")
for order, chapter, name, links in L:
print("%s | %s | %s | " % (chapter, cat[order], name), end='')
for a in links:
print(' [[%s]](%s)' % (code(a), a), end='')
print()
print()