def cmpfunc(item1,item2): return cmp(item1["term"].lower(),item2["term"].lower()) interm=0 terms=[] term={} fh=file("intergo.dct","r") cnt=1 for ln in fh.readlines(): if ln[0]=="#": pass elif len(ln.strip())==0: if interm: term["number"]=cnt cnt+=1 terms.append(term) term={} interm=0 else: if not interm: interm=1 items=ln.split("=",1) if len(items)==2: [key,value]=items value=value.strip() key=key.strip() if len(value)!=0: if term.has_key(key): if type(term[key])==type([]): term[key].append(value) else: term[key]=[term[key],value] else: term[key]=value fh.close() header=""" %s """ footer=""" """ termstr="%s%s" fh=file("terms.html","w") print >>fh,header % "Go terms" print >>fh,"

Go terms

" for item in terms: print >>fh,"
" print >>fh,"" % item["number"] print >>fh,"" if item.has_key("JP"): if type(item["JP"])==type([]): for term in item["JP"]: print >>fh,termstr % ("Japanese",term) else: print >>fh,termstr % ("Japanese",item["JP"]) if item.has_key("RK"): if type(item["RK"])==type([]): for term in item["RK"]: print >>fh,termstr % ("Korean",term) else: print >>fh,termstr % ("Korean",item["RK"]) if item.has_key("CH"): if type(item["CH"])==type([]): for term in item["CH"]: print >>fh,termstr % ("Chinese",term) else: print >>fh,termstr % ("Chinese",item["CH"]) print >>fh,"
" print >>fh,"

" if item.has_key("GB"): if type(item["GB"])==type([]): for st in item["GB"]: print >>fh,st else: print >>fh,item["GB"] print >>fh,"

" if item.has_key("GF"): if type(item["GF"])==type([]): for st in item["GF"]: [fname,other]=st.split(" ",1) print >>fh,"

" else: [fname,other]=item["GF"].split(" ",1) print >>fh,"

" print >>fh,"

" if item.has_key("CP"): if type(item["CP"])==type([]): for st in item["CP"]: print >>fh,st else: print >>fh,"

"+item["CP"] print >>fh,"

" if item.has_key("RF"): if type(item["RF"])==type([]): for st in item["RF"]: print >>fh,"

%s" % (st,st) else: print >>fh,"%s
" % (item["RF"],item["RF"]) print >>fh,"

" print >>fh,footer fh.close() fh=file("index.html","w") print >>fh, header % "Go term dictionary" print >>fh, """

Go term dictionary

""" print >>fh, footer fh.close() links=[] for term in terms: if term.has_key("JP"): if type(term["JP"])==type([]): for val in term["JP"]: link={"number":term["number"],"cat":term["CD"][0],"term":val} links.append(link) else: link={"number":term["number"],"cat":term["CD"][0],"term":term["JP"]} links.append(link) links.sort(cmpfunc) fh=file("japan.html","w") print >>fh, header % "Japanese go terms" print >>fh, "

Japanese go terms

" print >>fh, "

Championships

" print >>fh, "" print >>fh, "

Names

" print >>fh, "" print >>fh, "

Digits

" print >>fh, "" print >>fh, "

Polite

" print >>fh, "" print >>fh, "

Technical

" print >>fh, "" print >>fh, footer fh.close() links=[] for term in terms: if term.has_key("RK"): if type(term["RK"])==type([]): for val in term["RK"]: link={"number":term["number"],"cat":term["CD"][0],"term":val} links.append(link) else: link={"number":term["number"],"cat":term["CD"][0],"term":term["RK"]} links.append(link) links.sort(cmpfunc) fh=file("korea.html","w") print >>fh, header % "Korean go terms" print >>fh, "

Korean go terms

" print >>fh, "

Championships

" print >>fh, "" print >>fh, "

Names

" print >>fh, "" print >>fh, "

Digits

" print >>fh, "" print >>fh, "

Polite

" print >>fh, "" print >>fh, "

Technical

" print >>fh, "" print >>fh, footer fh.close() links=[] for term in terms: if term.has_key("CH"): if type(term["CH"])==type([]): for val in term["CH"]: link={"number":term["number"],"cat":term["CD"][0],"term":val} links.append(link) else: link={"number":term["number"],"cat":term["CD"][0],"term":term["CH"]} links.append(link) links.sort(cmpfunc) fh=file("china.html","w") print >>fh, header % "Chinese go terms" print >>fh, "

Chinese go terms

" print >>fh, "

Championships

" print >>fh, "" print >>fh, "

Names

" print >>fh, "" print >>fh, "

Digits

" print >>fh, "" print >>fh, "

Polite

" print >>fh, "" print >>fh, "

Technical

" print >>fh, "" print >>fh, footer fh.close() fh=file("style.css","w") print >>fh,""" .block { border: thin solid black; margin: 1em; padding: 1em } .term { font-weight: bold; } .lang { color: brown; font-style: italic; font-weight: bold; } """ fh.close()