#!/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=''' PSTricks Help Page

PSTricks Command Help

Command:

''' def cnv(s): # convert < and > characters to html ss=s.replace('<-','←') ss=ss.replace('<','<') ss=ss.replace('|','| ') return ss.replace('>','>') pagetail='\n' pagebody='' if thecmd[0:1]<>'\\': thecmd='\\'+thecmd print pagehead.replace('**thecmd**',thecmd) if thecmd: conn = sqlite3.connect('/Library/Webserver/Documents/pstCommands.db') c=conn.cursor() t=(thecmd,) c.execute('select cmdid, cmdname from Commands where cmdname=?',t) x=c.fetchone() cmdnum=0 while not (x is None): if x[1]==thecmd: cmdnum=int(x[0]) x=c.fetchone() if cmdnum==0: print "

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 '' print ''% thecmd print '' alt=0 for x in c: if alt: print '' else: print '' print '' alt=1-alt print '
Keywords for %s
KeywordKindDefaultDescription
'+x[0]+''+cnv(x[1])+''+x[2]+''+cnv(x[3])+'

' t=(cmdcat,cmdnum) if (cmdcat>0) and (cmdcat<>26): c.execute('select cmdID, cmdname from Commands where cmdCat=? and cmdID<>?',t) x=c.fetchone() if not (x is None): print '

Similar commands: ' while not(x is None): print ' ',x[1],' ' x=c.fetchone() print '

' print pagetail