forked from fcbond/ltdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakehome.py
100 lines (90 loc) · 2.5 KB
/
makehome.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
# Make the IndexPage
#
# ToDo
# * add error logs
# * calculate metadata
# * link license file
#
import sys, os
import datetime
from collections import OrderedDict
#import html/ltdb
(script, version, grmdir) = sys.argv
print("""
<html>
<head>
<title>{0} ltdb</title>
<link rel='stylesheet' type='text/css' href='lextypedb.css'/>
</head>
<body>
<h1>Welcome to {0}</h1>
<ul>
<li> <a href='../../cgi-bin/{0}/search.cgi'>Lexical Type Database for {0}</a> ( <a href='../../cgi-bin/{0}/search.cgi'>Search</a>)
<li> <a href='http://wiki.delph-in.net/moin/LkbLtdb'>Lexical Type Database Wiki</a>
<li> <a href='http://wiki.delph-in.net/moin/FrontPage'>DELPH-IN Wiki</a>
</ul>
""".format(version))
# if [ -n "$grammarurl" ]; then
# echo " <li> <a href='$grammarurl'>Grammar Home Page</a>" >> ${HTML_DIR}/index.html
# fi
MF = os.path.join(grmdir, 'METADATA')
LF = os.path.join(grmdir, 'LICENSE')
md = OrderedDict()
try:
fh = open(MF, 'r')
# Store configuration file values
for l in fh:
if l.strip() and l[0].isupper():
(att,val) = l.strip().split('=')
val=val.strip('"')
if val:
md[att]=val
except FileNotFoundError:
print("METADATA not found at {}".format(MF),file=sys.stderr)
try:
fh = open(LF, 'r')
except FileNotFoundError:
print("LICENSE not found at {}".format(LF),file=sys.stderr)
###
### print metadata
###
#required external resources
#associated resources
#FIXME: calculate numbers from LTDB
#lexical items
#lexical rules
#grammar rules
#features
#types (with glb)
print("<table>")
print(" <caption>Metadata for {}<caption>".format(version))
for a,v in md.items():
a=a.replace('_',' ')
if a not in 'VCS BCP_47':
a=a.title()
if v.startswith('http'):
print("<tr><td>{0}</td><td><a href='{1}'>{1}</a></td></tr>".format(a,v))
elif a.endswith('Email'):
print("<tr><td>{0}</td><td><a href='mailto:{1}?subject={2}'>{1}</a></td></tr>".format(a,v,version))
else:
print("<tr><td>{}</td><td>{}</td></tr>".format(a,v))
print("</table>")
print("""
<h3>Logs</h3>
<ul>
<li><a href='lkb.log'>LKB conversion log</a>
<li><a href='tdl.log'>TDL conversion log</a>
<li><a href='gold.log'>Gold profiles conversion log</a>
</ul>
<h3>Linguistic Type Database</h3>
<ul>
<li><a href='lt.db.7z'>Compressed SQLITE Database: lt.db.7z</a>
<li>Schema Diagram
<br>
<img src='lt-diagram.png'>
</ul>
""")
print(""" <p>Created on {}</p>
</html>
</body>""".format(datetime.datetime.now()))