forked from w3c-ccg/multibase
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen-algorithms-registry
executable file
·35 lines (28 loc) · 1.02 KB
/
gen-algorithms-registry
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
#!/usr/bin/env python3
#
# Script to generate the multihash algorithms registry from the CSV file
import codecs
import csv
import urllib.request
url = 'https://raw.githubusercontent.com/multiformats/multibase/master/multibase.csv'
stream = urllib.request.urlopen(url)
csvdata = csv.reader(codecs.iterdecode(stream, 'utf-8'))
print("""
<texttable anchor="mh-registry-table" title="Multihash Algorithms Registry">
<ttcol align="center">Algorithm</ttcol>
<ttcol align="center">Identifier (character)</ttcol>
<ttcol align="center">Status</ttcol>
<ttcol align="center">Specification</ttcol>
""")
for line in csvdata:
codec = line[0].strip()
identifier = line[1].strip()
spec = line[2].strip().replace(
'rfc4648', '<xref target="RFC4648">RFC 4648</xref>')
status = line[3].strip()
if(identifier == 'code'):
continue
if(status != 'default'):
continue
print(f' <c>{codec}</c><c>{identifier}</c><c>{status}</c><c>{spec}</c>')
print(' </texttable>')