import libxml2 import libxslt import cgi class dirLibXML: def __init__(self): pass def OutputDirLib(self,lib,libname): resultText = "\n" resultText += "\n" resultText += "\n" resultText += "Dir "+libname+"\n" resultText += "\n" resultText += "\n" resultText += "

dir() listing for "+libname+"

\n" resultText += "
\n" lLibXML = dir(lib) for entry in lLibXML: if entry[0] != "_": resultText += "
\n" resultText += "+ \n" resultText += ""+entry+" \n" resultText += "("+libname+"."+entry+")
\n" libdoc = eval(libname+"."+entry+".__doc__") resultText += "
\n" if libdoc != None: resultText += cgi.escape(str(libdoc)) #submod = module(entry) sublib = libname+"."+entry lSubLibXML = eval("[name for name in dir("+sublib+") if name[0] != '_']") if len(lSubLibXML) > 0: resultText += "
\n" for subEntry in lSubLibXML: if subEntry[0] != "_": resultText += "
\n" resultText += "+ \n" resultText += ""+subEntry+" \n" resultText += "("+libname+"."+entry+"."+subEntry+")
\n" sublibdoc = eval(libname+"."+entry+"."+subEntry+".__doc__") if sublibdoc != None: resultText += "
"+cgi.escape(str(sublibdoc))+"
\n" resultText += "
\n" resultText += "
\n" resultText += "
\n" fileName = "dir"+libname+".html" resultText += "\n" resultText += "\n" resultFile = open(fileName, 'w+') resultFile.write(resultText) resultFile.close() return if __name__ == '__main__': dirLibXMLObj = dirLibXML() dirLibXMLObj.OutputDirLib(libxml2,"libxml2") dirLibXMLObj.OutputDirLib(libxslt,"libxslt")