def menu(self, base='/', pct='50', showpct='', exclude=r'python\d\.\d|test|tut\d|tutorial'): # The coverage module uses all-lower-case names. base = base.lower().rstrip(os.sep) yield TEMPLATE_MENU yield TEMPLATE_FORM % locals() # Start by showing links for parent paths yield "<div id='crumbs'>" path = '' atoms = base.split(os.sep) atoms.pop() for atom in atoms: path += atom + os.sep yield ("<a href='menu?base=%s&exclude=%s'>%s</a> %s" % (path, quote_plus(exclude), atom, os.sep)) yield '</div>' yield "<div id='tree'>" # Then display the tree tree = get_tree(base, exclude, self.coverage) if not tree: yield '<p>No modules covered.</p>' else: for chunk in _show_branch(tree, base, '/', pct, showpct == 'checked', exclude, coverage=self.coverage): yield chunk yield '</div>' yield '</body></html>'
def menu(self, base='/', pct='50', showpct='', exclude='python\\d\\.\\d|test|tut\\d|tutorial'): base = base.lower().rstrip(os.sep) yield TEMPLATE_MENU yield TEMPLATE_FORM % locals() yield "<div id='crumbs'>" path = '' atoms = base.split(os.sep) atoms.pop() for atom in atoms: path += atom + os.sep yield "<a href='menu?base=%s&exclude=%s'>%s</a> %s" % ( path, quote_plus(exclude), atom, os.sep) yield '</div>' yield "<div id='tree'>" tree = get_tree(base, exclude, self.coverage) if not tree: yield '<p>No modules covered.</p>' else: for chunk in _show_branch(tree, base, '/', pct, showpct == 'checked', exclude, coverage=self.coverage): yield chunk yield '</div>' yield '</body></html>'
def menu(self, base="/", pct="50", showpct="", exclude=r'python\d\.\d|test|tut\d|tutorial'): # The coverage module uses all-lower-case names. base = base.lower().rstrip(os.sep) yield TEMPLATE_MENU yield TEMPLATE_FORM % locals() # Start by showing links for parent paths yield "<div id='crumbs'>" path = "" atoms = base.split(os.sep) atoms.pop() for atom in atoms: path += atom + os.sep yield ("<a href='menu?base=%s&exclude=%s'>%s</a> %s" % (path, quote_plus(exclude), atom, os.sep)) yield "</div>" yield "<div id='tree'>" # Then display the tree tree = get_tree(base, exclude, self.coverage) if not tree: yield "<p>No modules covered.</p>" else: for chunk in _show_branch(tree, base, "/", pct, showpct=='checked', exclude, coverage=self.coverage): yield chunk yield "</div>" yield "</body></html>"
def menu(self, base = '/', pct = '50', showpct = '', exclude = 'python\\d\\.\\d|test|tut\\d|tutorial'): base = base.lower().rstrip(os.sep) yield TEMPLATE_MENU yield TEMPLATE_FORM % locals() yield "<div id='crumbs'>" path = '' atoms = base.split(os.sep) atoms.pop() for atom in atoms: path += atom + os.sep yield "<a href='menu?base=%s&exclude=%s'>%s</a> %s" % (path, quote_plus(exclude), atom, os.sep) yield '</div>' yield "<div id='tree'>" tree = get_tree(base, exclude, self.coverage) if not tree: yield '<p>No modules covered.</p>' else: for chunk in _show_branch(tree, base, '/', pct, showpct == 'checked', exclude, coverage=self.coverage): yield chunk yield '</div>' yield '</body></html>'
def _show_branch(root, base, path, pct=0, showpct=False, exclude="", coverage=the_coverage): # Show the directory name and any of our children dirs = [k for k, v in root.items() if v] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield "| " * relpath.count(os.sep) yield ("<a class='directory' " "href='menu?base=%s&exclude=%s'>%s</a>\n" % (newpath, quote_plus(exclude), name)) for chunk in _show_branch(root[name], base, newpath, pct, showpct, exclude, coverage=coverage): yield chunk # Now list the files if path.lower().startswith(base): relpath = path[len(base):] files = [k for k, v in root.items() if not v] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = "" if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except: # Yes, we really want to pass on all errors. pass else: pc = _percent(statements, missing) pc_str = ("%3d%% " % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ("| " * (relpath.count(os.sep) + 1), pc_str, newpath, name)
def _show_branch(root, base, path, pct=0, showpct=False, exclude="", coverage=the_coverage): # Show the directory name and any of our children dirs = [k for k, v in root.items() if v] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield "| " * relpath.count(os.sep) yield ( "<a class='directory' " "href='menu?base=%s&exclude=%s'>%s</a>\n" % (newpath, quote_plus(exclude), name) ) for chunk in _show_branch( root[name], base, newpath, pct, showpct, exclude, coverage=coverage ): yield chunk # Now list the files if path.lower().startswith(base): relpath = path[len(base):] files = [k for k, v in root.items() if not v] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = "" if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except: # Yes, we really want to pass on all errors. pass else: pc = _percent(statements, missing) pc_str = ("%3d%% " % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ("| " * (relpath.count(os.sep) + 1), pc_str, newpath, name)
def _show_branch(root, base, path, pct=0, showpct=False, exclude='', coverage=the_coverage): dirs = [k for k, v in root.items() if v] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield '| ' * relpath.count(os.sep) yield "<a class='directory' href='menu?base=%s&exclude=%s'>%s</a>\n" % ( newpath, quote_plus(exclude), name) for chunk in _show_branch(root[name], base, newpath, pct, showpct, exclude, coverage=coverage): yield chunk if path.lower().startswith(base): relpath = path[len(base):] files = [k for k, v in root.items() if not v] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = '' if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except: pass else: pc = _percent(statements, missing) pc_str = ('%3d%% ' % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ('| ' * (relpath.count(os.sep) + 1), pc_str, newpath, name)
def _show_branch(root, base, path, pct = 0, showpct = False, exclude = '', coverage = the_coverage): dirs = [ k for k, v in root.items() if v ] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield '| ' * relpath.count(os.sep) yield "<a class='directory' href='menu?base=%s&exclude=%s'>%s</a>\n" % (newpath, quote_plus(exclude), name) for chunk in _show_branch(root[name], base, newpath, pct, showpct, exclude, coverage=coverage): yield chunk if path.lower().startswith(base): relpath = path[len(base):] files = [ k for k, v in root.items() if not v ] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = '' if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except: pass else: pc = _percent(statements, missing) pc_str = ('%3d%% ' % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ('| ' * (relpath.count(os.sep) + 1), pc_str, newpath, name)