Changeset 551
- Timestamp:
- 08/24/05 01:23:59
- Files:
-
- trunk/cherrypy/lib/autoreload.py (modified) (1 diff)
- trunk/cherrypy/lib/covercp.py (modified) (12 diffs)
- trunk/cherrypy/test/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/autoreload.py
r480 r551 17 17 if filename.endswith(".pyc"): 18 18 filename = filename[:-1] 19 mtime = os.stat(filename).st_mtime 19 try: 20 mtime = os.stat(filename).st_mtime 21 except OSError: 22 sys.exit(3) # force reload 20 23 if filename not in mtimes: 21 24 mtimes[filename] = mtime trunk/cherrypy/lib/covercp.py
r550 r551 78 78 <style> 79 79 body {font: 9pt Arial, serif;} 80 #tree {font: 8pt Courier, sans-serif;} 80 #tree { 81 font-size: 8pt; 82 font-family: Andale Mono, monospace; 83 white-space: pre; 84 } 81 85 #tree a:active, a:focus { 82 background-color: #EEEEFF;86 background-color: black; 83 87 padding: 1px; 84 border: 1px solid #9999FF; 88 color: white; 89 border: 0px solid #9999FF; 85 90 -moz-outline-style: none; 86 } 87 .fail {color: red;} 88 .pass {color: #888;} 89 #pct {text-align: right;} 90 h3 { font-size: small; font-weight: bold; font-style: italic; margin-top: 5px;} 91 } 92 .fail { color: red;} 93 .pass { color: #888;} 94 #pct { text-align: right;} 95 h3 { 96 font-size: small; 97 font-weight: bold; 98 font-style: italic; 99 margin-top: 5px; 100 } 91 101 input { border: 1px solid #ccc; padding: 2px; } 102 .directory { 103 color: #933; 104 font-style: italic; 105 font-weight: bold; 106 font-size: 10pt; 107 } 108 .file { 109 color: #400; 110 } 111 a { text-decoration: none; } 112 #crumbs { 113 color: white; 114 font-size: 8pt; 115 font-family: Andale Mono, monospace; 116 width: 100%; 117 background-color: black; 118 } 119 #crumbs a { 120 color: #f88; 121 } 122 #options { 123 line-height: 2.3em; 124 border: 1px solid black; 125 background-color: #eee; 126 padding: 4px; 127 } 128 #exclude { 129 width: 100%; 130 margin-bottom: 3px; 131 border: 1px solid #999; 132 } 133 #submit { 134 background-color: black; 135 color: white; 136 border: 0; 137 margin-bottom: -9px; 138 } 92 139 </style> 93 140 </head> … … 96 143 97 144 TEMPLATE_FORM = """ 145 <div id="options"> 98 146 <form action='menu' method=GET> 99 147 <input type='hidden' name='base' value='%(base)s' /> 100 <h3>Options</h3> 101 <input type='checkbox' %(showpct)s name='showpct' value='checked'/> 102 show percentages <br /> 148 Show percentages <input type='checkbox' %(showpct)s name='showpct' value='checked' /><br /> 103 149 Hide files over <input type='text' id='pct' name='pct' value='%(pct)s' size='3' />%%<br /> 104 150 Exclude files matching<br /> … … 106 152 <br /> 107 153 108 <input type='submit' value='Change view' /> 109 </form>""" 154 <input type='submit' value='Change view' id="submit"/> 155 </form> 156 </div>""" 110 157 111 158 TEMPLATE_FRAMESET = """<html> … … 154 201 </tr>\n""" 155 202 156 157 def _skip_file(path, exclude): 158 if exclude: 159 return bool(re.search(exclude, path)) 203 TEMPLATE_ITEM = "%s%s<a class='file' href='report?name=%s' target='main'>%s</a>\n" 160 204 161 205 def _percent(statements, missing): … … 166 210 return 0 167 211 168 def _show_branch(root, base ="", path="", pct=0, showpct=False, exclude=""):212 def _show_branch(root, base, path, pct=0, showpct=False, exclude=""): 169 213 170 214 # Show the directory name and any of our children 171 dirs = [k for k, v in root.iteritems() if v is not None]215 dirs = [k for k, v in root.iteritems() if v] 172 216 dirs.sort() 173 217 for name in dirs: 174 if path: 175 newpath = os.sep.join((path, name)) 176 else: 177 newpath = name 218 newpath = os.path.join(path, name) 178 219 179 220 if newpath.startswith(base): 180 221 relpath = newpath[len(base):] 181 yield "<nobr>" + ("| " * relpath.count(os.sep)) + "<b>" 182 yield ("<a href='menu?base=%s&exclude=%s'>%s</a>" % 183 (newpath, urllib.quote_plus(exclude), name)) 184 yield "</b></nobr><br />\n" 222 yield "| " * relpath.count(os.sep) 223 yield "<a class='directory' href='menu?base=%s&exclude=%s'>%s</a>\n" % \ 224 (newpath, urllib.quote_plus(exclude), name) 185 225 186 226 for chunk in _show_branch(root[name], base, newpath, pct, showpct, exclude): … … 190 230 if path.startswith(base): 191 231 relpath = path[len(base):] 192 files = [k for k, v in root.iteritems() if v is None]232 files = [k for k, v in root.iteritems() if not v] 193 233 files.sort() 194 234 for name in files: 195 if path: 196 newpath = os.sep.join((path, name)) 197 else: 198 newpath = name 235 newpath = os.path.join(path, name) 199 236 200 237 pc_str = "" … … 213 250 pc_str = "<span class='pass'>%s</span>" % pc_str 214 251 215 yield ("<nobr>%s%s<a href='report?name=%s' target='main'>%s</a></nobr><br />\n" 216 % ("| " * (relpath.count(os.sep) + 1), pc_str, newpath, name)) 252 yield TEMPLATE_ITEM % ("| " * (relpath.count(os.sep) + 1), 253 pc_str, newpath, name) 254 255 def _skip_file(path, exclude): 256 if exclude: 257 return bool(re.search(exclude, path)) 258 259 def _graft(path, tree): 260 d = tree 261 262 p = path 263 atoms = [] 264 while True: 265 p, tail = os.path.split(p) 266 if not tail: 267 break 268 atoms.append(tail) 269 atoms.append(p) 270 if p != "/": 271 atoms.append("/") 272 273 atoms.reverse() 274 for node in atoms: 275 if node: 276 d = d.setdefault(node, {}) 217 277 218 278 def get_tree(base, exclude): … … 222 282 runs = coverage.cexecuted.keys() 223 283 if runs: 224 tree = {}225 def graft(path):226 head, tail = os.path.split(path)227 if tail:228 return graft(head).setdefault(tail, {})229 else:230 return tree.setdefault(head.strip(r"\/"), {})231 232 284 for path in runs: 233 285 if not _skip_file(path, exclude) and not os.path.isdir(path): 234 head, tail = os.path.split(path) 235 if head.startswith(base): 236 graft(head)[tail] = None 286 _graft(path, tree) 287 print tree 237 288 return tree 238 239 289 240 290 class CoverStats(object): … … 244 294 index.exposed = True 245 295 246 def menu(self, base=" ", pct="50", showpct="",296 def menu(self, base="/", pct="50", showpct="", 247 297 exclude=r'python\d\.\d|test|tut\d|tutorial'): 248 298 … … 253 303 yield TEMPLATE_FORM % locals() 254 304 255 yield "<div id='tree'>"256 257 305 # Start by showing links for parent paths 306 yield "<div id='crumbs'>" 258 307 path = "" 259 308 atoms = base.split(os.sep) … … 261 310 for atom in atoms: 262 311 path += atom + os.sep 263 yield ("< nobr><b><a href='menu?base=%s&exclude=%s'>%s</a></b></nobr>%s\n"312 yield ("<a href='menu?base=%s&exclude=%s'>%s</a> %s" 264 313 % (path, urllib.quote_plus(exclude), atom, os.sep)) 265 314 yield "</div>" 315 316 yield "<div id='tree'>" 317 318 # Then display the tree 266 319 tree = get_tree(base, exclude) 267 320 if not tree: 268 321 yield "<p>No modules covered.</p>" 269 322 else: 270 # Now show all visible branches 271 yield "<br />" 272 for chunk in _show_branch(tree, base, "", pct, showpct=='checked', exclude): 323 for chunk in _show_branch(tree, base, "/", pct, 324 showpct=='checked', exclude): 273 325 yield chunk 274 326 … … 316 368 def serve(path=localFile, port=8080): 317 369 if coverage is None: 318 raise ImportError(" <p>The coverage module could not be imported.</p>")370 raise ImportError("The coverage module could not be imported.") 319 371 coverage.cache_default = path 320 372 trunk/cherrypy/test/test.py
r533 r551 210 210 sys.stdout.flush() 211 211 name = os.path.split(morf)[1] 212 if morf.find('test') != -1: 213 continue 212 214 try: 213 215 _, statements, _, missing, readable = self.coverage.analysis2(morf)

