diff options
author | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2016-09-08 16:12:31 +0300 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2016-09-08 16:12:31 +0300 |
commit | dc574c422886d192b33a48b036d0e9839c3cc6e0 (patch) | |
tree | c2f25676df9d99ee26521367aa1e01692d788a86 /cherrypy/lib/covercp.py | |
parent | 2035500ef638a079665a29548aea74761d8877ef (diff) | |
download | cherrypy-git-dc574c422886d192b33a48b036d0e9839c3cc6e0.tar.gz |
Convert all strings to conform single-quoted style
pre-commit run double-quote-string-fixer --all-files
Diffstat (limited to 'cherrypy/lib/covercp.py')
-rw-r--r-- | cherrypy/lib/covercp.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/cherrypy/lib/covercp.py b/cherrypy/lib/covercp.py index 5f8da630..cf1743cb 100644 --- a/cherrypy/lib/covercp.py +++ b/cherrypy/lib/covercp.py @@ -30,7 +30,7 @@ import cherrypy from cherrypy._cpcompat import quote_plus -localFile = os.path.join(os.path.dirname(__file__), "coverage.cache") +localFile = os.path.join(os.path.dirname(__file__), 'coverage.cache') the_coverage = None try: @@ -46,8 +46,8 @@ except ImportError: import warnings warnings.warn( - "No code coverage will be performed; " - "coverage.py could not be imported.") + 'No code coverage will be performed; ' + 'coverage.py could not be imported.') def start(): pass @@ -197,7 +197,7 @@ def _percent(statements, missing): return 0 -def _show_branch(root, base, path, pct=0, showpct=False, exclude="", +def _show_branch(root, base, path, pct=0, showpct=False, exclude='', coverage=the_coverage): # Show the directory name and any of our children @@ -208,7 +208,7 @@ def _show_branch(root, base, path, pct=0, showpct=False, exclude="", if newpath.lower().startswith(base): relpath = newpath[len(base):] - yield "| " * relpath.count(os.sep) + yield '| ' * relpath.count(os.sep) yield ( "<a class='directory' " "href='menu?base=%s&exclude=%s'>%s</a>\n" % @@ -229,7 +229,7 @@ def _show_branch(root, base, path, pct=0, showpct=False, exclude="", for name in files: newpath = os.path.join(path, name) - pc_str = "" + pc_str = '' if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) @@ -238,13 +238,13 @@ def _show_branch(root, base, path, pct=0, showpct=False, exclude="", pass else: pc = _percent(statements, missing) - pc_str = ("%3d%% " % pc).replace(' ', ' ') + 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), + yield TEMPLATE_ITEM % ('| ' * (relpath.count(os.sep) + 1), pc_str, newpath, name) @@ -264,8 +264,8 @@ def _graft(path, tree): break atoms.append(tail) atoms.append(p) - if p != "/": - atoms.append("/") + if p != '/': + atoms.append('/') atoms.reverse() for node in atoms: @@ -299,7 +299,7 @@ class CoverStats(object): return TEMPLATE_FRAMESET % self.root.lower() @cherrypy.expose - def menu(self, base="/", pct="50", showpct="", + def menu(self, base='/', pct='50', showpct='', exclude=r'python\d\.\d|test|tut\d|tutorial'): # The coverage module uses all-lower-case names. @@ -310,36 +310,36 @@ class CoverStats(object): # Start by showing links for parent paths yield "<div id='crumbs'>" - path = "" + 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>' yield "<div id='tree'>" # Then display the tree tree = get_tree(base, exclude, self.coverage) if not tree: - yield "<p>No modules covered.</p>" + yield '<p>No modules covered.</p>' else: - for chunk in _show_branch(tree, base, "/", pct, + for chunk in _show_branch(tree, base, '/', pct, showpct == 'checked', exclude, coverage=self.coverage): yield chunk - yield "</div>" - yield "</body></html>" + yield '</div>' + yield '</body></html>' def annotated_file(self, filename, statements, excluded, missing): source = open(filename, 'r') buffer = [] for lineno, line in enumerate(source.readlines()): lineno += 1 - line = line.strip("\n\r") + line = line.strip('\n\r') empty_the_buffer = True if lineno in excluded: template = TEMPLATE_LOC_EXCLUDED @@ -375,7 +375,7 @@ class CoverStats(object): def serve(path=localFile, port=8080, root=None): if coverage is None: - raise ImportError("The coverage module could not be imported.") + raise ImportError('The coverage module could not be imported.') from coverage import coverage cov = coverage(data_file=path) cov.load() @@ -383,9 +383,9 @@ def serve(path=localFile, port=8080, root=None): import cherrypy cherrypy.config.update({'server.socket_port': int(port), 'server.thread_pool': 10, - 'environment': "production", + 'environment': 'production', }) cherrypy.quickstart(CoverStats(cov, root)) -if __name__ == "__main__": +if __name__ == '__main__': serve(*tuple(sys.argv[1:])) |