def MakeStatsPage(): """ Generate Statistics Page """ if metaInfo.indexPage['stat'] == '': # statistics disabled return from progress import printProgress from os import path as os_path printProgress(_('Creating statistics page'), logname) outfile = fopen(metaInfo.htmlDir + metaInfo.indexPage['stat'], 'w', metaInfo.encoding) outfile.write(MakeHTMLHeader('stat', True, 'initCharts();')) try: copy2(os_path.join(metaInfo.scriptpath, 'diagram.js'), os_path.join(metaInfo.htmlDir, 'diagram.js')) except IOError: logger.error(_('I/O error while copying %(source)s to %(target)s'), { 'source': _('javascript file'), 'target': _('HTML-Dir') }) generateOutput(outfile) outfile.write(MakeHTMLFooter('stat')) outfile.close()
def CreateIndexPage(): """Generates the main index page""" printProgress(_('Creating site index page'), logname) from iz_tools.system import fopen outfile = fopen(os_path.join(metaInfo.htmlDir, 'index.html'), 'w', metaInfo.encoding) outfile.write(MakeHTMLHeader('Index')) outfile.write('<H1 ID="infotitle">' + metaInfo.title_prefix + ' ' + _('HyperSQL Reference') + '</H1>\n') outfile.write( '<TABLE ID="projectinfo" ALIGN="center"><TR><TD VALIGN="middle" ALIGN="center">\n' ) if metaInfo.projectLogo != '': logoname = os_path.split(metaInfo.projectLogo)[1] outfile.write(' <IMG ALIGN="center" SRC="' + logoname + '" ALT="Logo"><BR><BR><BR>\n') outfile.write(metaInfo.projectInfo) outfile.write('</TD></TR></TABLE>\n') outfile.write(MakeHTMLFooter('Index')) outfile.close()
def MakeFileIndex(objectType): """ Generate HTML index page for all files, ordered by path names (filepath) or file names (file) @param string objectType either 'file' or 'filepath' @param string html_title main heading (H1) for the generated content @param object outfile file object to write() to """ if objectType not in ['file', 'filepath']: # unsupported type return if metaInfo.indexPage[objectType] == '': # this index is disabled return outfile = fopen( os_path.join(metaInfo.htmlDir, metaInfo.indexPage[objectType]), "w", metaInfo.encoding) outfile.write(MakeHTMLHeader(objectType)) if objectType == 'file': printProgress(_("Creating filename no path index"), logname) html_title = _('Index Of All Files By File Name') else: printProgress(_("Creating filename by path index"), logname) html_title = _('Index Of All Files By Path Name') filenametuplelist = [] for file_info in metaInfo.fileInfoList: # skip all non-sql files if file_info.fileType != "sql": continue if objectType == 'file': filenametuplelist.append( (os_path.split(file_info.fileName)[1].upper(), file_info)) else: filenametuplelist.append((file_info.fileName.upper(), file_info)) filenametuplelist.sort(key=lambda x: x[0]) outfile.write("<H1>" + html_title + "</H1>\n") outfile.write("<TABLE CLASS='apilist'>\n") i = 0 for filenametuple in filenametuplelist: file_name = filenametuple[1].fileName temp = filenametuple[1].getHtmlName() if objectType == 'file': outfile.write(" <TR CLASS='tr%d'><TD><A href=\"" % (i % 2) + temp + "\">" + os_path.split(file_name)[1]) else: outfile.write(" <TR CLASS='tr%d'><TD><A href=\"" % (i % 2) + temp + "\">" + file_name[len(metaInfo.topLevelDirectory) + 1:]) outfile.write("</A></TD></TR>\n") i += 1 outfile.write("</TABLE>\n") outfile.write(MakeHTMLFooter(objectType)) outfile.close()
def MakeFileIndex(objectType): """ Generate HTML index page for all files, ordered by path names (filepath) or file names (file) @param string objectType either 'file' or 'filepath' @param string html_title main heading (H1) for the generated content @param object outfile file object to write() to """ if objectType not in ['file','filepath']: # unsupported type return if metaInfo.indexPage[objectType] == '': # this index is disabled return outfile = fopen(os_path.join(metaInfo.htmlDir,metaInfo.indexPage[objectType]), "w", metaInfo.encoding) outfile.write(MakeHTMLHeader(objectType)) if objectType == 'file': printProgress(_("Creating filename no path index"), logname) html_title = _('Index Of All Files By File Name') else: printProgress(_("Creating filename by path index"), logname) html_title = _('Index Of All Files By Path Name') filenametuplelist = [] for file_info in metaInfo.fileInfoList: # skip all non-sql files if file_info.fileType != "sql": continue if objectType == 'file': filenametuplelist.append((os_path.split(file_info.fileName)[1].upper(), file_info)) else: filenametuplelist.append((file_info.fileName.upper(), file_info)) filenametuplelist.sort(key=lambda x: x[0]) outfile.write("<H1>"+html_title+"</H1>\n") outfile.write("<TABLE CLASS='apilist'>\n") i = 0 for filenametuple in filenametuplelist: file_name = filenametuple[1].fileName temp = filenametuple[1].getHtmlName() if objectType == 'file': outfile.write(" <TR CLASS='tr%d'><TD><A href=\"" % (i % 2) + temp + "\">" + os_path.split(file_name)[1]) else: outfile.write(" <TR CLASS='tr%d'><TD><A href=\"" % (i % 2) + temp + "\">" + file_name[len(metaInfo.topLevelDirectory)+1:]) outfile.write("</A></TD></TR>\n") i += 1 outfile.write("</TABLE>\n") outfile.write(MakeHTMLFooter(objectType)) outfile.close()
def put(self, fname, ctype, content): """ Save content to cache @param self @param string fname name of the original file @param string ctype type of the cached part @param string content """ cname = self.makename(fname, ctype) cfile = fopen(cname, 'w', 'zip') cont = content.encode(self.encoding) cfile.write(cont) cfile.close()
def put(self,fname,ctype,content): """ Save content to cache @param self @param string fname name of the original file @param string ctype type of the cached part @param string content """ cname = self.makename(fname,ctype) cfile = fopen(cname,'w','zip') cont = content.encode(self.encoding) cfile.write( cont ) cfile.close()
def get(self, fname, ctype): """ Get the string from cache content for a given file @param self @param string fname name of the original file @param string ctype type of the cached part @return string content (empty string if none) """ cname = self.makename(fname, ctype) if not os.path.isfile(cname): return '' # no cache cfile = fopen(cname, 'r', 'zip') cont = cfile.read().decode(self.encoding) cfile.close() return cont
def get(self,fname,ctype): """ Get the string from cache content for a given file @param self @param string fname name of the original file @param string ctype type of the cached part @return string content (empty string if none) """ cname = self.makename(fname,ctype) if not os.path.isfile(cname): return '' # no cache cfile = fopen(cname,'r','zip') cont = cfile.read().decode(self.encoding) cfile.close() return cont
def CreateIndexPage(): """Generates the main index page""" printProgress(_('Creating site index page'), logname) from iz_tools.system import fopen outfile = fopen(os_path.join(metaInfo.htmlDir,'index.html'), 'w', metaInfo.encoding) outfile.write(MakeHTMLHeader('Index')) outfile.write('<H1 STYLE="margin-top:100px">' + metaInfo.title_prefix + ' '+_('HyperSQL Reference')+'</H1>\n') outfile.write('<BR><BR>\n') outfile.write('<TABLE ID="projectinfo" ALIGN="center"><TR><TD VALIGN="middle" ALIGN="center">\n') if metaInfo.projectLogo != '': logoname = os_path.split(metaInfo.projectLogo)[1] outfile.write(' <IMG ALIGN="center" SRC="' + logoname + '" ALT="Logo"><BR><BR><BR>\n') outfile.write(metaInfo.projectInfo) outfile.write('</TD></TR></TABLE>\n') outfile.write('<BR><BR>\n') outfile.write(MakeHTMLFooter('Index')) outfile.close()
def MakeStatsPage(): """ Generate Statistics Page """ if metaInfo.indexPage['stat'] == '': # statistics disabled return from progress import printProgress from os import path as os_path printProgress(_('Creating statistics page'), logname) outfile = fopen(metaInfo.htmlDir + metaInfo.indexPage['stat'], 'w', metaInfo.encoding) outfile.write(MakeHTMLHeader('stat',True,'initCharts();')) try: copy2(os_path.join(metaInfo.scriptpath,'diagram.js'), os_path.join(metaInfo.htmlDir,'diagram.js')) except IOError: logger.error(_('I/O error while copying %(source)s to %(target)s'), {'source':_('javascript file'),'target':_('HTML-Dir')}) generateOutput(outfile) outfile.write(MakeHTMLFooter('stat')) outfile.close()
def CreateDepGraphIndex(): """ Generate the depgraphs and their index page """ from depgraph import depgraph from shutil import copy2 if metaInfo.useCache: import hypercore.cache if metaInfo.indexPage['depgraph'] == '': return g = depgraph(metaInfo.graphvizMod, metaInfo.encoding, metaInfo.depGraphDelTmp) if not g.deps_ok: # we cannot do anything logger.error(_('Graphviz trouble - unable to generate the graph')) return i = 0 pbarInit(_('Creating dependency graphs'), i, metaInfo.depGraphCount, logname) g.set_fontname(metaInfo.fontName) g.set_fontsize(metaInfo.fontSize) g.set_ranksep(metaInfo.graphRankSepDot, 'dot') g.set_ranksep(metaInfo.graphRankSepTwopi, 'twopi') g.set_ranksep(metaInfo.graphLenFdp, 'fdp') g.set_ranksep(metaInfo.graphLenNeato, 'neato') g.set_ranksep(metaInfo.graphDistCirco, 'circo') if metaInfo.useCache: cache = hypercore.cache.cache(metaInfo.cacheDirectory) def makePng(gtyp, i): """ Create the graph file @param string gtyp which depGraph to process (file2file, file2object...) """ if metaInfo.makeDepGraph[gtyp]: if metaInfo.depGraph[gtyp]: gname = 'depgraph_' + gtyp + '.png' # check the cache first done = False if metaInfo.useCache: tmp = cache.get(gtyp, 'depdata').split('\n') if tmp == metaInfo.depGraph[gtyp]: try: copy2(os_path.join(metaInfo.cacheDirectory, gname), os_path.join(metaInfo.htmlDir, gname)) done = True except: logger.error( _('Error while copying %s from cache'), gname) if not done: g.set_graph(metaInfo.depGraph[gtyp]) res = g.make_graph(metaInfo.htmlDir + gname) if res == '': if metaInfo.useCache: try: cache.put(gtyp, 'depdata', '\n'.join(metaInfo.depGraph[gtyp])) copy2( os_path.join(metaInfo.htmlDir, gname), os_path.join(metaInfo.cacheDirectory, gname)) except: logger.error( _('Error while copying %s to cache'), gname) else: logger.error( _('Graphviz threw an error:') + res.strip()) else: # no data, no graph if gtyp == 'file2file': name = _('file to file') elif gtyp == 'file2object': name = _('file to object') elif gtyp == 'object2file': name = _('object to file') elif gtyp == 'object2object': name = _('object to object') else: name = _('unknown dependency graph type') logger.debug(_('No dependency data for %s'), name) i += 1 pbarUpdate(i) return i # draw the graphs i = makePng('file2file', i) i = makePng('file2object', i) i = makePng('object2file', i) i = makePng('object2object', i) outfile = fopen( os_path.join(metaInfo.htmlDir, metaInfo.indexPage['depgraph']), "w", metaInfo.encoding) outfile.write(MakeHTMLHeader('depgraph')) outfile.write("<H1>" + _('Dependency Graph') + "</H1>\n") sel = _( 'Access from' ) + " <SELECT NAME=\"graph\" onChange=\"document.getElementById('depimg').src='depgraph_'+this.value+'.png';\">" if metaInfo.makeDepGraph['file2file']: sel += "<OPTION VALUE='file2file'>" + _("file to file") + "</OPTION>" if metaInfo.makeDepGraph['file2object']: sel += "<OPTION VALUE='file2object'>" + _( "file to object") + "</OPTION>" if metaInfo.makeDepGraph['object2file']: sel += "<OPTION VALUE='object2file'>" + _( "object to file") + "</OPTION>" if metaInfo.makeDepGraph['object2object']: sel += "<OPTION VALUE='object2object'>" + _( "object to object") + "</OPTION>" sel += "</SELECT><BR>" for obj in ['file2file', 'file2object', 'object2file', 'object2object']: if metaInfo.makeDepGraph[obj]: defsrc = 'depgraph_' + obj break outfile.write('<DIV ALIGN="center">\n' + sel + '\n<IMG ID="depimg" SRC="' + defsrc + '.png" ALT="' + _('Dependency Graph') + '" ALIGN="center">\n</DIV>\n') outfile.write(MakeHTMLFooter('depgraph')) outfile.close() pbarClose()
def CreateDepGraphIndex(): """ Generate the depgraphs and their index page """ from depgraph import depgraph from shutil import copy2 if metaInfo.useCache: import hypercore.cache if metaInfo.indexPage['depgraph']=='': return g = depgraph(metaInfo.graphvizMod, metaInfo.encoding, metaInfo.depGraphDelTmp) if not g.deps_ok: # we cannot do anything logger.error(_('Graphviz trouble - unable to generate the graph')) return i = 0 pbarInit(_('Creating dependency graphs'), i, metaInfo.depGraphCount, logname) g.set_fontname(metaInfo.fontName) g.set_fontsize(metaInfo.fontSize) g.set_ranksep(metaInfo.graphRankSepDot,'dot') g.set_ranksep(metaInfo.graphRankSepTwopi,'twopi') g.set_ranksep(metaInfo.graphLenFdp,'fdp') g.set_ranksep(metaInfo.graphLenNeato,'neato') g.set_ranksep(metaInfo.graphDistCirco,'circo') if metaInfo.useCache: cache = hypercore.cache.cache(metaInfo.cacheDirectory) def makePng(gtyp,i): """ Create the graph file @param string gtyp which depGraph to process (file2file, file2object...) """ if metaInfo.makeDepGraph[gtyp]: if metaInfo.depGraph[gtyp]: gname = 'depgraph_'+gtyp+'.png' # check the cache first done = False if metaInfo.useCache: tmp = cache.get(gtyp,'depdata').split('\n') if tmp==metaInfo.depGraph[gtyp]: try: copy2(os_path.join(metaInfo.cacheDirectory,gname), os_path.join(metaInfo.htmlDir,gname)) done = True except: logger.error(_('Error while copying %s from cache'), gname) if not done: g.set_graph(metaInfo.depGraph[gtyp]) res = g.make_graph(metaInfo.htmlDir + gname) if res=='': if metaInfo.useCache: try: cache.put(gtyp,'depdata','\n'.join(metaInfo.depGraph[gtyp])) copy2(os_path.join(metaInfo.htmlDir,gname), os_path.join(metaInfo.cacheDirectory,gname)) except: logger.error(_('Error while copying %s to cache'), gname) else: logger.error(_('Graphviz threw an error:') + res.strip()) else: # no data, no graph if gtyp=='file2file': name = _('file to file') elif gtyp=='file2object': name = _('file to object') elif gtyp=='object2file': name = _('object to file') elif gtyp=='object2object': name = _('object to object') else: name = _('unknown dependency graph type') logger.debug(_('No dependency data for %s'), name) i += 1 pbarUpdate(i) return i # draw the graphs i = makePng('file2file',i) i = makePng('file2object',i) i = makePng('object2file',i) i = makePng('object2object',i) outfile = fopen(os_path.join(metaInfo.htmlDir,metaInfo.indexPage['depgraph']), "w", metaInfo.encoding) outfile.write(MakeHTMLHeader('depgraph')) outfile.write("<H1>"+_('Dependency Graph')+"</H1>\n") sel = _('Access from') + " <SELECT NAME=\"graph\" onChange=\"document.getElementById('depimg').src='depgraph_'+this.value+'.png';\">" if metaInfo.makeDepGraph['file2file']: sel += "<OPTION VALUE='file2file'>" + _("file to file") + "</OPTION>" if metaInfo.makeDepGraph['file2object']: sel += "<OPTION VALUE='file2object'>" + _("file to object") + "</OPTION>" if metaInfo.makeDepGraph['object2file']: sel += "<OPTION VALUE='object2file'>" + _("object to file") + "</OPTION>" if metaInfo.makeDepGraph['object2object']: sel += "<OPTION VALUE='object2object'>" + _("object to object") + "</OPTION>" sel += "</SELECT><BR>" for obj in ['file2file','file2object','object2file','object2object']: if metaInfo.makeDepGraph[obj]: defsrc = 'depgraph_' + obj break; outfile.write('<DIV ALIGN="center">\n' + sel + '\n<IMG ID="depimg" SRC="'+ defsrc + '.png" ALT="'+_('Dependency Graph')+'" ALIGN="center">\n</DIV>\n') outfile.write(MakeHTMLFooter('depgraph')) outfile.close() pbarClose()