#!/usr/bin/env python import cgi, sys, sqlite3 import cgitb; cgitb.enable() theform=cgi.FieldStorage() if not theform.has_key('cmd'): thecmd = '' else: thecmd = theform['cmd'].value pkgs=('pstricks','pst-plot','pst-node','pstricks-add','pst-nodeExtras','pst-3dplot','pst-tree','multido','pst-eps','pst-bspline','pst-grapha','pst-coil','pst-text') tab=u'\x09' bdelim=("{","(","[","") edelim=("}",")","]","") bgon='' bgoff='' print "Content-type: text/html\r\n" pagehead='''
Command not found
" c.execute("select cmdname from Commands where cmdname LIKE '"+thecmd+"%' order by cmdname") x=c.fetchone() print 'Similar commands:
' while not (x is None): print ' ',x[0],' ' x=c.fetchone() print '
' else: t=(cmdnum,) c.execute('select * from Commands where cmdID=?',t) x=c.fetchone() #print x---there should be only one cmdcat=int(x[1]) desc=x[6].split(tab) isOpt=x[8] ti=[] ti.append(thecmd) if x[2]==1: ti.append(bgon+"*"+bgoff) if x[9]==1: ti.append(bgon+"[<kwds>]"+bgoff) L=len(x[7]) # delimiters delim=x[7] for i in range(0,L): k=int(delim[i]) s=bdelim[k]+desc[i].replace('<-','←')+edelim[k] s=cnv(s) if isOpt[i]=='1': s=bgon+s+bgoff ti.append(s) if x[10]==1: ti.append("(<coords>)"+bgon+"..."+bgoff) #ti.append("% "+x[5]+' ['+pkgs[x[11]]+']') #print "" print 'Syntax:',''.join(ti),'
' print '(Gray background indicates optional argument, "←" shows default value, if omitted.)' print 'Synopsis: ['+pkgs[x[11]]+']',cnv(x[5]) if x[9]==1: ss="select parName,parPat,parDefault,parDescription from Parameters where (parLimTo="+str(cmdnum)+") or ((parLimTo=0) and (parCat=0 or parCat="+str(x[1])+")) group by parName,parPat,parDefault,parDescription order by parname" c.execute(ss) print '
Keyword | Kind | Default | Description |
---|---|---|---|
'+x[0]+' | '+cnv(x[1])+' | '+x[2]+' | '+cnv(x[3])+' |
Similar commands: ' while not(x is None): print ' ',x[1],' ' x=c.fetchone() print '
' print pagetail