##// END OF EJS Templates
Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein -
r5760:0145f9af default
parent child Browse files
Show More
@@ -57,7 +57,7 b' def convert(ui, src, dest=None, revmapfi'
57 exclude path/to/file
57 exclude path/to/file
58
58
59 rename from/file to/file
59 rename from/file to/file
60
60
61 The 'include' directive causes a file, or all files under a
61 The 'include' directive causes a file, or all files under a
62 directory, to be included in the destination repository, and the
62 directory, to be included in the destination repository, and the
63 exclusion of all other files and dirs not explicitely included.
63 exclusion of all other files and dirs not explicitely included.
@@ -104,13 +104,13 b' class converter_source(object):'
104
104
105 def getchangedfiles(self, rev, i):
105 def getchangedfiles(self, rev, i):
106 """Return the files changed by rev compared to parent[i].
106 """Return the files changed by rev compared to parent[i].
107
107
108 i is an index selecting one of the parents of rev. The return
108 i is an index selecting one of the parents of rev. The return
109 value should be the list of files that are different in rev and
109 value should be the list of files that are different in rev and
110 this parent.
110 this parent.
111
111
112 If rev has no parents, i is None.
112 If rev has no parents, i is None.
113
113
114 This function is only needed to support --filemap
114 This function is only needed to support --filemap
115 """
115 """
116 raise NotImplementedError()
116 raise NotImplementedError()
@@ -279,7 +279,7 b' class mapfile(dict):'
279 self.order.append(key)
279 self.order.append(key)
280 super(mapfile, self).__setitem__(key, value)
280 super(mapfile, self).__setitem__(key, value)
281 fp.close()
281 fp.close()
282
282
283 def __setitem__(self, key, value):
283 def __setitem__(self, key, value):
284 if self.fp is None:
284 if self.fp is None:
285 try:
285 try:
@@ -208,7 +208,7 b' class svn_source(converter_source):'
208 self.heads.append(brev)
208 self.heads.append(brev)
209
209
210 if oldmodule:
210 if oldmodule:
211 self.tags = '%s/%s' % (oldmodule, tags)
211 self.tags = '%s/%s' % (oldmodule, tags)
212 else:
212 else:
213 self.tags = '/%s' % tags
213 self.tags = '/%s' % tags
214
214
@@ -714,7 +714,7 b' class svn_sink(converter_sink, commandli'
714
714
715 def join(self, name):
715 def join(self, name):
716 return os.path.join(self.wc, '.svn', name)
716 return os.path.join(self.wc, '.svn', name)
717
717
718 def revmapfile(self):
718 def revmapfile(self):
719 return self.join('hg-shamap')
719 return self.join('hg-shamap')
720
720
@@ -750,7 +750,7 b' class svn_sink(converter_sink, commandli'
750 if not path.startswith('/'):
750 if not path.startswith('/'):
751 path = '/' + path
751 path = '/' + path
752 path = 'file://' + path
752 path = 'file://' + path
753
753
754 ui.status(_('initializing svn wc %r\n') % os.path.basename(wcpath))
754 ui.status(_('initializing svn wc %r\n') % os.path.basename(wcpath))
755 self.run0('checkout', path, wcpath)
755 self.run0('checkout', path, wcpath)
756
756
@@ -849,7 +849,7 b' class svn_sink(converter_sink, commandli'
849 if files:
849 if files:
850 self.run('add', quiet=True, *files)
850 self.run('add', quiet=True, *files)
851 return files
851 return files
852
852
853 def tidy_dirs(self, names):
853 def tidy_dirs(self, names):
854 dirs = list(self.dirs_of(names))
854 dirs = list(self.dirs_of(names))
855 dirs.sort(reverse=True)
855 dirs.sort(reverse=True)
@@ -13,7 +13,7 b''
13 # querying of information, and an extension to mercurial named hgk.py,
13 # querying of information, and an extension to mercurial named hgk.py,
14 # which provides hooks for hgk to get information. hgk can be found in
14 # which provides hooks for hgk to get information. hgk can be found in
15 # the contrib directory, and hgk.py can be found in the hgext
15 # the contrib directory, and hgk.py can be found in the hgext
16 # directory.
16 # directory.
17 #
17 #
18 # To load the hgext.py extension, add it to your .hgrc file (you have
18 # To load the hgext.py extension, add it to your .hgrc file (you have
19 # to use your global $HOME/.hgrc file, not one in a repository). You
19 # to use your global $HOME/.hgrc file, not one in a repository). You
@@ -309,10 +309,10 b' def revlist(ui, repo, *revs, **opts):'
309 def config(ui, repo, **opts):
309 def config(ui, repo, **opts):
310 """print extension options"""
310 """print extension options"""
311 def writeopt(name, value):
311 def writeopt(name, value):
312 ui.write('k=%s\nv=%s\n' % (name, value))
312 ui.write('k=%s\nv=%s\n' % (name, value))
313
313
314 writeopt('vdiff', ui.config('hgk', 'vdiff', ''))
314 writeopt('vdiff', ui.config('hgk', 'vdiff', ''))
315
315
316
316
317 def view(ui, repo, *etc, **opts):
317 def view(ui, repo, *etc, **opts):
318 "start interactive history viewer"
318 "start interactive history viewer"
@@ -773,10 +773,10 b' class changeset_templater(changeset_prin'
773 def showcopies(**args):
773 def showcopies(**args):
774 c = [{'name': x[0], 'source': x[1]} for x in copies]
774 c = [{'name': x[0], 'source': x[1]} for x in copies]
775 return showlist('file_copy', c, plural='file_copies', **args)
775 return showlist('file_copy', c, plural='file_copies', **args)
776
776
777 files = []
777 files = []
778 def getfiles():
778 def getfiles():
779 if not files:
779 if not files:
780 files[:] = self.repo.status(
780 files[:] = self.repo.status(
781 log.parents(changenode)[0], changenode)[:3]
781 log.parents(changenode)[0], changenode)[:3]
782 return files
782 return files
@@ -717,7 +717,7 b' def debuginstall(ui):'
717 ui.write(_(" (Current patch tool may be incompatible with patch,"
717 ui.write(_(" (Current patch tool may be incompatible with patch,"
718 " or misconfigured. Please check your .hgrc file)\n"))
718 " or misconfigured. Please check your .hgrc file)\n"))
719 else:
719 else:
720 ui.write(_(" Internal patcher failure, please report this error"
720 ui.write(_(" Internal patcher failure, please report this error"
721 " to http://www.selenic.com/mercurial/bts\n"))
721 " to http://www.selenic.com/mercurial/bts\n"))
722 problems += patchproblems
722 problems += patchproblems
723
723
@@ -1702,7 +1702,7 b' def manifest(ui, repo, node=None, rev=No'
1702 The manifest is the list of files being version controlled. If no revision
1702 The manifest is the list of files being version controlled. If no revision
1703 is given then the first parent of the working directory is used.
1703 is given then the first parent of the working directory is used.
1704
1704
1705 With -v flag, print file permissions, symlink and executable bits. With
1705 With -v flag, print file permissions, symlink and executable bits. With
1706 --debug flag, print file revision hashes.
1706 --debug flag, print file revision hashes.
1707 """
1707 """
1708
1708
@@ -483,7 +483,7 b' class workingctx(changectx):'
483 return self._manifest.flags(path)
483 return self._manifest.flags(path)
484 except KeyError:
484 except KeyError:
485 return ''
485 return ''
486
486
487 pnode = self._parents[0].changeset()[0]
487 pnode = self._parents[0].changeset()[0]
488 orig = self._repo.dirstate.copies().get(path, path)
488 orig = self._repo.dirstate.copies().get(path, path)
489 node, flag = self._repo.manifest.find(pnode, orig)
489 node, flag = self._repo.manifest.find(pnode, orig)
@@ -21,7 +21,7 b' def _statusmessage(code):'
21 from BaseHTTPServer import BaseHTTPRequestHandler
21 from BaseHTTPServer import BaseHTTPRequestHandler
22 responses = BaseHTTPRequestHandler.responses
22 responses = BaseHTTPRequestHandler.responses
23 return responses.get(code, ('Error', 'Unknown error'))[0]
23 return responses.get(code, ('Error', 'Unknown error'))[0]
24
24
25 def statusmessage(code):
25 def statusmessage(code):
26 return '%d %s' % (code, _statusmessage(code))
26 return '%d %s' % (code, _statusmessage(code))
27
27
@@ -75,7 +75,7 b' class hgwebdir(object):'
75 try:
75 try:
76
76
77 virtual = req.env.get("PATH_INFO", "").strip('/')
77 virtual = req.env.get("PATH_INFO", "").strip('/')
78
78
79 # a static file
79 # a static file
80 if virtual.startswith('static/') or 'static' in req.form:
80 if virtual.startswith('static/') or 'static' in req.form:
81 static = os.path.join(templater.templatepath(), 'static')
81 static = os.path.join(templater.templatepath(), 'static')
@@ -122,7 +122,7 b' class hgwebdir(object):'
122 # prefixes not found
122 # prefixes not found
123 tmpl = self.templater(req)
123 tmpl = self.templater(req)
124 req.respond(404, tmpl("notfound", repo=virtual))
124 req.respond(404, tmpl("notfound", repo=virtual))
125
125
126 except ErrorResponse, err:
126 except ErrorResponse, err:
127 tmpl = self.templater(req)
127 tmpl = self.templater(req)
128 req.respond(err.code, tmpl('error', error=err.message or ''))
128 req.respond(err.code, tmpl('error', error=err.message or ''))
@@ -173,7 +173,7 b' class hgwebdir(object):'
173
173
174 parts = [req.env['PATH_INFO'], name]
174 parts = [req.env['PATH_INFO'], name]
175 if req.env['SCRIPT_NAME']:
175 if req.env['SCRIPT_NAME']:
176 parts.insert(0, req.env['SCRIPT_NAME'])
176 parts.insert(0, req.env['SCRIPT_NAME'])
177 url = ('/'.join(parts).replace("//", "/")) + '/'
177 url = ('/'.join(parts).replace("//", "/")) + '/'
178
178
179 # update time with local timezone
179 # update time with local timezone
@@ -58,7 +58,7 b' class wsgirequest(object):'
58 except socket.error, inst:
58 except socket.error, inst:
59 if inst[0] != errno.ECONNRESET:
59 if inst[0] != errno.ECONNRESET:
60 raise
60 raise
61
61
62 def write(self, *things):
62 def write(self, *things):
63 self.respond('200 Script output follows', *things)
63 self.respond('200 Script output follows', *things)
64
64
@@ -86,7 +86,7 b' class wsgirequest(object):'
86 self.header(headers)
86 self.header(headers)
87
87
88 def wsgiapplication(app_maker):
88 def wsgiapplication(app_maker):
89 application = app_maker()
89 application = app_maker()
90 def run_wsgi(env, respond):
90 def run_wsgi(env, respond):
91 application(env, respond)
91 application(env, respond)
92 return run_wsgi
92 return run_wsgi
@@ -288,7 +288,7 b' class localrepository(repo.repository):'
288 '''
288 '''
289
289
290 self.tags()
290 self.tags()
291
291
292 return self._tagstypecache.get(tagname)
292 return self._tagstypecache.get(tagname)
293
293
294 def _hgtagsnodes(self):
294 def _hgtagsnodes(self):
@@ -818,7 +818,7 b' def selectfile(afile_orig, bfile_orig, h'
818 fname = (afile in bfile) and afile or bfile
818 fname = (afile in bfile) and afile or bfile
819 elif gooda:
819 elif gooda:
820 fname = afile
820 fname = afile
821
821
822 if not fname:
822 if not fname:
823 if not nullb:
823 if not nullb:
824 fname = (afile in bfile) and afile or bfile
824 fname = (afile in bfile) and afile or bfile
@@ -826,7 +826,7 b' def selectfile(afile_orig, bfile_orig, h'
826 fname = afile
826 fname = afile
827 else:
827 else:
828 raise PatchError(_("undefined source and destination files"))
828 raise PatchError(_("undefined source and destination files"))
829
829
830 return fname, missing
830 return fname, missing
831
831
832 class linereader:
832 class linereader:
@@ -1029,7 +1029,7 b' def applydiff(ui, fp, changed, strip=1, '
1029 for gp in gitpatches:
1029 for gp in gitpatches:
1030 if gp.op in ('COPY', 'RENAME'):
1030 if gp.op in ('COPY', 'RENAME'):
1031 copyfile(gp.oldpath, gp.path)
1031 copyfile(gp.oldpath, gp.path)
1032 changed[gp.path] = (gp.op, gp)
1032 changed[gp.path] = (gp.op, gp)
1033 else:
1033 else:
1034 raise util.Abort(_('unsupported parser state: %s') % state)
1034 raise util.Abort(_('unsupported parser state: %s') % state)
1035
1035
@@ -1709,7 +1709,7 b' def uirepr(s):'
1709
1709
1710 def hidepassword(url):
1710 def hidepassword(url):
1711 '''replaces the password in the url string by three asterisks (***)
1711 '''replaces the password in the url string by three asterisks (***)
1712
1712
1713 >>> hidepassword('http://www.example.com/some/path#fragment')
1713 >>> hidepassword('http://www.example.com/some/path#fragment')
1714 'http://www.example.com/some/path#fragment'
1714 'http://www.example.com/some/path#fragment'
1715 >>> hidepassword('http://me@www.example.com/some/path#fragment')
1715 >>> hidepassword('http://me@www.example.com/some/path#fragment')
@@ -105,20 +105,20 b' class StatementFindingAstVisitor(compile'
105 self.excluded = excluded
105 self.excluded = excluded
106 self.suite_spots = suite_spots
106 self.suite_spots = suite_spots
107 self.excluding_suite = 0
107 self.excluding_suite = 0
108
108
109 def doRecursive(self, node):
109 def doRecursive(self, node):
110 for n in node.getChildNodes():
110 for n in node.getChildNodes():
111 self.dispatch(n)
111 self.dispatch(n)
112
112
113 visitStmt = visitModule = doRecursive
113 visitStmt = visitModule = doRecursive
114
114
115 def doCode(self, node):
115 def doCode(self, node):
116 if hasattr(node, 'decorators') and node.decorators:
116 if hasattr(node, 'decorators') and node.decorators:
117 self.dispatch(node.decorators)
117 self.dispatch(node.decorators)
118 self.recordAndDispatch(node.code)
118 self.recordAndDispatch(node.code)
119 else:
119 else:
120 self.doSuite(node, node.code)
120 self.doSuite(node, node.code)
121
121
122 visitFunction = visitClass = doCode
122 visitFunction = visitClass = doCode
123
123
124 def getFirstLine(self, node):
124 def getFirstLine(self, node):
@@ -138,14 +138,14 b' class StatementFindingAstVisitor(compile'
138 for n in node.getChildNodes():
138 for n in node.getChildNodes():
139 lineno = max(lineno, self.getLastLine(n))
139 lineno = max(lineno, self.getLastLine(n))
140 return lineno
140 return lineno
141
141
142 def doStatement(self, node):
142 def doStatement(self, node):
143 self.recordLine(self.getFirstLine(node))
143 self.recordLine(self.getFirstLine(node))
144
144
145 visitAssert = visitAssign = visitAssTuple = visitPrint = \
145 visitAssert = visitAssign = visitAssTuple = visitPrint = \
146 visitPrintnl = visitRaise = visitSubscript = visitDecorators = \
146 visitPrintnl = visitRaise = visitSubscript = visitDecorators = \
147 doStatement
147 doStatement
148
148
149 def visitPass(self, node):
149 def visitPass(self, node):
150 # Pass statements have weird interactions with docstrings. If this
150 # Pass statements have weird interactions with docstrings. If this
151 # pass statement is part of one of those pairs, claim that the statement
151 # pass statement is part of one of those pairs, claim that the statement
@@ -154,10 +154,10 b' class StatementFindingAstVisitor(compile'
154 if l:
154 if l:
155 lines = self.suite_spots.get(l, [l,l])
155 lines = self.suite_spots.get(l, [l,l])
156 self.statements[lines[1]] = 1
156 self.statements[lines[1]] = 1
157
157
158 def visitDiscard(self, node):
158 def visitDiscard(self, node):
159 # Discard nodes are statements that execute an expression, but then
159 # Discard nodes are statements that execute an expression, but then
160 # discard the results. This includes function calls, so we can't
160 # discard the results. This includes function calls, so we can't
161 # ignore them all. But if the expression is a constant, the statement
161 # ignore them all. But if the expression is a constant, the statement
162 # won't be "executed", so don't count it now.
162 # won't be "executed", so don't count it now.
163 if node.expr.__class__.__name__ != 'Const':
163 if node.expr.__class__.__name__ != 'Const':
@@ -171,7 +171,7 b' class StatementFindingAstVisitor(compile'
171 return self.recordLine(self.getFirstLine(node))
171 return self.recordLine(self.getFirstLine(node))
172 else:
172 else:
173 return 0
173 return 0
174
174
175 def recordLine(self, lineno):
175 def recordLine(self, lineno):
176 # Returns a bool, whether the line is included or excluded.
176 # Returns a bool, whether the line is included or excluded.
177 if lineno:
177 if lineno:
@@ -195,9 +195,9 b' class StatementFindingAstVisitor(compile'
195 self.statements[lineno] = 1
195 self.statements[lineno] = 1
196 return 1
196 return 1
197 return 0
197 return 0
198
198
199 default = recordNodeLine
199 default = recordNodeLine
200
200
201 def recordAndDispatch(self, node):
201 def recordAndDispatch(self, node):
202 self.recordNodeLine(node)
202 self.recordNodeLine(node)
203 self.dispatch(node)
203 self.dispatch(node)
@@ -208,7 +208,7 b' class StatementFindingAstVisitor(compile'
208 self.excluding_suite = 1
208 self.excluding_suite = 1
209 self.recordAndDispatch(body)
209 self.recordAndDispatch(body)
210 self.excluding_suite = exsuite
210 self.excluding_suite = exsuite
211
211
212 def doPlainWordSuite(self, prevsuite, suite):
212 def doPlainWordSuite(self, prevsuite, suite):
213 # Finding the exclude lines for else's is tricky, because they aren't
213 # Finding the exclude lines for else's is tricky, because they aren't
214 # present in the compiler parse tree. Look at the previous suite,
214 # present in the compiler parse tree. Look at the previous suite,
@@ -222,11 +222,11 b' class StatementFindingAstVisitor(compile'
222 break
222 break
223 else:
223 else:
224 self.doSuite(None, suite)
224 self.doSuite(None, suite)
225
225
226 def doElse(self, prevsuite, node):
226 def doElse(self, prevsuite, node):
227 if node.else_:
227 if node.else_:
228 self.doPlainWordSuite(prevsuite, node.else_)
228 self.doPlainWordSuite(prevsuite, node.else_)
229
229
230 def visitFor(self, node):
230 def visitFor(self, node):
231 self.doSuite(node, node.body)
231 self.doSuite(node, node.body)
232 self.doElse(node.body, node)
232 self.doElse(node.body, node)
@@ -256,14 +256,14 b' class StatementFindingAstVisitor(compile'
256 else:
256 else:
257 self.doSuite(a, h)
257 self.doSuite(a, h)
258 self.doElse(node.handlers[-1][2], node)
258 self.doElse(node.handlers[-1][2], node)
259
259
260 def visitTryFinally(self, node):
260 def visitTryFinally(self, node):
261 self.doSuite(node, node.body)
261 self.doSuite(node, node.body)
262 self.doPlainWordSuite(node.body, node.final)
262 self.doPlainWordSuite(node.body, node.final)
263
263
264 def visitWith(self, node):
264 def visitWith(self, node):
265 self.doSuite(node, node.body)
265 self.doSuite(node, node.body)
266
266
267 def visitGlobal(self, node):
267 def visitGlobal(self, node):
268 # "global" statements don't execute like others (they don't call the
268 # "global" statements don't execute like others (they don't call the
269 # trace function), so don't record their line numbers.
269 # trace function), so don't record their line numbers.
@@ -283,7 +283,7 b' class coverage:'
283 # A dictionary with an entry for (Python source file name, line number
283 # A dictionary with an entry for (Python source file name, line number
284 # in that file) if that line has been executed.
284 # in that file) if that line has been executed.
285 c = {}
285 c = {}
286
286
287 # A map from canonical Python source file name to a dictionary in
287 # A map from canonical Python source file name to a dictionary in
288 # which there's an entry for each line number that has been
288 # which there's an entry for each line number that has been
289 # executed.
289 # executed.
@@ -311,12 +311,12 b' class coverage:'
311 self.relative_dir = os.path.normcase(os.path.abspath(os.curdir)+os.sep)
311 self.relative_dir = os.path.normcase(os.path.abspath(os.curdir)+os.sep)
312 self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]')
312 self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]')
313
313
314 # t(f, x, y). This method is passed to sys.settrace as a trace function.
314 # t(f, x, y). This method is passed to sys.settrace as a trace function.
315 # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and
315 # See [van Rossum 2001-07-20b, 9.2] for an explanation of sys.settrace and
316 # the arguments and return value of the trace function.
316 # the arguments and return value of the trace function.
317 # See [van Rossum 2001-07-20a, 3.2] for a description of frame and code
317 # See [van Rossum 2001-07-20a, 3.2] for a description of frame and code
318 # objects.
318 # objects.
319
319
320 def t(self, f, w, unused): #pragma: no cover
320 def t(self, f, w, unused): #pragma: no cover
321 if w == 'line':
321 if w == 'line':
322 #print "Executing %s @ %d" % (f.f_code.co_filename, f.f_lineno)
322 #print "Executing %s @ %d" % (f.f_code.co_filename, f.f_lineno)
@@ -324,7 +324,7 b' class coverage:'
324 for c in self.cstack:
324 for c in self.cstack:
325 c[(f.f_code.co_filename, f.f_lineno)] = 1
325 c[(f.f_code.co_filename, f.f_lineno)] = 1
326 return self.t
326 return self.t
327
327
328 def help(self, error=None): #pragma: no cover
328 def help(self, error=None): #pragma: no cover
329 if error:
329 if error:
330 print error
330 print error
@@ -376,14 +376,14 b' class coverage:'
376 args_needed = (settings.get('execute')
376 args_needed = (settings.get('execute')
377 or settings.get('annotate')
377 or settings.get('annotate')
378 or settings.get('report'))
378 or settings.get('report'))
379 action = (settings.get('erase')
379 action = (settings.get('erase')
380 or settings.get('collect')
380 or settings.get('collect')
381 or args_needed)
381 or args_needed)
382 if not action:
382 if not action:
383 help_fn("You must specify at least one of -e, -x, -c, -r, or -a.")
383 help_fn("You must specify at least one of -e, -x, -c, -r, or -a.")
384 if not args_needed and args:
384 if not args_needed and args:
385 help_fn("Unexpected arguments: %s" % " ".join(args))
385 help_fn("Unexpected arguments: %s" % " ".join(args))
386
386
387 self.parallel_mode = settings.get('parallel-mode')
387 self.parallel_mode = settings.get('parallel-mode')
388 self.get_ready()
388 self.get_ready()
389
389
@@ -401,7 +401,7 b' class coverage:'
401 self.collect()
401 self.collect()
402 if not args:
402 if not args:
403 args = self.cexecuted.keys()
403 args = self.cexecuted.keys()
404
404
405 ignore_errors = settings.get('ignore-errors')
405 ignore_errors = settings.get('ignore-errors')
406 show_missing = settings.get('show-missing')
406 show_missing = settings.get('show-missing')
407 directory = settings.get('directory=')
407 directory = settings.get('directory=')
@@ -421,7 +421,7 b' class coverage:'
421 self.usecache = usecache
421 self.usecache = usecache
422 if cache_file and not self.cache:
422 if cache_file and not self.cache:
423 self.cache_default = cache_file
423 self.cache_default = cache_file
424
424
425 def get_ready(self, parallel_mode=False):
425 def get_ready(self, parallel_mode=False):
426 if self.usecache and not self.cache:
426 if self.usecache and not self.cache:
427 self.cache = os.environ.get(self.cache_env, self.cache_default)
427 self.cache = os.environ.get(self.cache_env, self.cache_default)
@@ -429,7 +429,7 b' class coverage:'
429 self.cache += "." + gethostname() + "." + str(os.getpid())
429 self.cache += "." + gethostname() + "." + str(os.getpid())
430 self.restore()
430 self.restore()
431 self.analysis_cache = {}
431 self.analysis_cache = {}
432
432
433 def start(self, parallel_mode=False):
433 def start(self, parallel_mode=False):
434 self.get_ready()
434 self.get_ready()
435 if self.nesting == 0: #pragma: no cover
435 if self.nesting == 0: #pragma: no cover
@@ -437,7 +437,7 b' class coverage:'
437 if hasattr(threading, 'settrace'):
437 if hasattr(threading, 'settrace'):
438 threading.settrace(self.t)
438 threading.settrace(self.t)
439 self.nesting += 1
439 self.nesting += 1
440
440
441 def stop(self):
441 def stop(self):
442 self.nesting -= 1
442 self.nesting -= 1
443 if self.nesting == 0: #pragma: no cover
443 if self.nesting == 0: #pragma: no cover
@@ -461,7 +461,7 b' class coverage:'
461 def begin_recursive(self):
461 def begin_recursive(self):
462 self.cstack.append(self.c)
462 self.cstack.append(self.c)
463 self.xstack.append(self.exclude_re)
463 self.xstack.append(self.exclude_re)
464
464
465 def end_recursive(self):
465 def end_recursive(self):
466 self.c = self.cstack.pop()
466 self.c = self.cstack.pop()
467 self.exclude_re = self.xstack.pop()
467 self.exclude_re = self.xstack.pop()
@@ -541,7 +541,7 b' class coverage:'
541 self.canonical_filename_cache[filename] = cf
541 self.canonical_filename_cache[filename] = cf
542 return self.canonical_filename_cache[filename]
542 return self.canonical_filename_cache[filename]
543
543
544 # canonicalize_filenames(). Copy results from "c" to "cexecuted",
544 # canonicalize_filenames(). Copy results from "c" to "cexecuted",
545 # canonicalizing filenames on the way. Clear the "c" map.
545 # canonicalizing filenames on the way. Clear the "c" map.
546
546
547 def canonicalize_filenames(self):
547 def canonicalize_filenames(self):
@@ -573,7 +573,7 b' class coverage:'
573 # in the source code, (3) a list of lines of excluded statements,
573 # in the source code, (3) a list of lines of excluded statements,
574 # and (4), a map of line numbers to multi-line line number ranges, for
574 # and (4), a map of line numbers to multi-line line number ranges, for
575 # statements that cross lines.
575 # statements that cross lines.
576
576
577 def analyze_morf(self, morf):
577 def analyze_morf(self, morf):
578 if self.analysis_cache.has_key(morf):
578 if self.analysis_cache.has_key(morf):
579 return self.analysis_cache[morf]
579 return self.analysis_cache[morf]
@@ -600,26 +600,26 b' class coverage:'
600 if len(tree) == 3 and type(tree[2]) == type(1):
600 if len(tree) == 3 and type(tree[2]) == type(1):
601 return tree[2]
601 return tree[2]
602 tree = tree[1]
602 tree = tree[1]
603
603
604 def last_line_of_tree(self, tree):
604 def last_line_of_tree(self, tree):
605 while True:
605 while True:
606 if len(tree) == 3 and type(tree[2]) == type(1):
606 if len(tree) == 3 and type(tree[2]) == type(1):
607 return tree[2]
607 return tree[2]
608 tree = tree[-1]
608 tree = tree[-1]
609
609
610 def find_docstring_pass_pair(self, tree, spots):
610 def find_docstring_pass_pair(self, tree, spots):
611 for i in range(1, len(tree)):
611 for i in range(1, len(tree)):
612 if self.is_string_constant(tree[i]) and self.is_pass_stmt(tree[i+1]):
612 if self.is_string_constant(tree[i]) and self.is_pass_stmt(tree[i+1]):
613 first_line = self.first_line_of_tree(tree[i])
613 first_line = self.first_line_of_tree(tree[i])
614 last_line = self.last_line_of_tree(tree[i+1])
614 last_line = self.last_line_of_tree(tree[i+1])
615 self.record_multiline(spots, first_line, last_line)
615 self.record_multiline(spots, first_line, last_line)
616
616
617 def is_string_constant(self, tree):
617 def is_string_constant(self, tree):
618 try:
618 try:
619 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.expr_stmt
619 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.expr_stmt
620 except:
620 except:
621 return False
621 return False
622
622
623 def is_pass_stmt(self, tree):
623 def is_pass_stmt(self, tree):
624 try:
624 try:
625 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.pass_stmt
625 return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.pass_stmt
@@ -629,7 +629,7 b' class coverage:'
629 def record_multiline(self, spots, i, j):
629 def record_multiline(self, spots, i, j):
630 for l in range(i, j+1):
630 for l in range(i, j+1):
631 spots[l] = (i, j)
631 spots[l] = (i, j)
632
632
633 def get_suite_spots(self, tree, spots):
633 def get_suite_spots(self, tree, spots):
634 """ Analyze a parse tree to find suite introducers which span a number
634 """ Analyze a parse tree to find suite introducers which span a number
635 of lines.
635 of lines.
@@ -671,7 +671,7 b' class coverage:'
671 # treat them differently, especially in the common case of a
671 # treat them differently, especially in the common case of a
672 # function with a doc string and a single pass statement.
672 # function with a doc string and a single pass statement.
673 self.find_docstring_pass_pair(tree[i], spots)
673 self.find_docstring_pass_pair(tree[i], spots)
674
674
675 elif tree[i][0] == symbol.simple_stmt:
675 elif tree[i][0] == symbol.simple_stmt:
676 first_line = self.first_line_of_tree(tree[i])
676 first_line = self.first_line_of_tree(tree[i])
677 last_line = self.last_line_of_tree(tree[i])
677 last_line = self.last_line_of_tree(tree[i])
@@ -696,7 +696,7 b' class coverage:'
696 tree = parser.suite(text+'\n\n').totuple(1)
696 tree = parser.suite(text+'\n\n').totuple(1)
697 self.get_suite_spots(tree, suite_spots)
697 self.get_suite_spots(tree, suite_spots)
698 #print "Suite spots:", suite_spots
698 #print "Suite spots:", suite_spots
699
699
700 # Use the compiler module to parse the text and find the executable
700 # Use the compiler module to parse the text and find the executable
701 # statements. We add newlines to be impervious to final partial lines.
701 # statements. We add newlines to be impervious to final partial lines.
702 statements = {}
702 statements = {}
@@ -806,7 +806,7 b' class coverage:'
806 else:
806 else:
807 globbed.append(morf)
807 globbed.append(morf)
808 morfs = globbed
808 morfs = globbed
809
809
810 morfs = self.filter_by_prefix(morfs, omit_prefixes)
810 morfs = self.filter_by_prefix(morfs, omit_prefixes)
811 morfs.sort(self.morf_name_compare)
811 morfs.sort(self.morf_name_compare)
812
812
@@ -873,7 +873,7 b' class coverage:'
873 except:
873 except:
874 if not ignore_errors:
874 if not ignore_errors:
875 raise
875 raise
876
876
877 def annotate_file(self, filename, statements, excluded, missing, directory=None):
877 def annotate_file(self, filename, statements, excluded, missing, directory=None):
878 source = open(filename, 'r')
878 source = open(filename, 'r')
879 if directory:
879 if directory:
@@ -901,7 +901,7 b' class coverage:'
901 if self.blank_re.match(line):
901 if self.blank_re.match(line):
902 dest.write(' ')
902 dest.write(' ')
903 elif self.else_re.match(line):
903 elif self.else_re.match(line):
904 # Special logic for lines containing only 'else:'.
904 # Special logic for lines containing only 'else:'.
905 # See [GDR 2001-12-04b, 3.2].
905 # See [GDR 2001-12-04b, 3.2].
906 if i >= len(statements) and j >= len(missing):
906 if i >= len(statements) and j >= len(missing):
907 dest.write('! ')
907 dest.write('! ')
@@ -925,40 +925,40 b' class coverage:'
925 the_coverage = coverage()
925 the_coverage = coverage()
926
926
927 # Module functions call methods in the singleton object.
927 # Module functions call methods in the singleton object.
928 def use_cache(*args, **kw):
928 def use_cache(*args, **kw):
929 return the_coverage.use_cache(*args, **kw)
929 return the_coverage.use_cache(*args, **kw)
930
930
931 def start(*args, **kw):
931 def start(*args, **kw):
932 return the_coverage.start(*args, **kw)
932 return the_coverage.start(*args, **kw)
933
933
934 def stop(*args, **kw):
934 def stop(*args, **kw):
935 return the_coverage.stop(*args, **kw)
935 return the_coverage.stop(*args, **kw)
936
936
937 def erase(*args, **kw):
937 def erase(*args, **kw):
938 return the_coverage.erase(*args, **kw)
938 return the_coverage.erase(*args, **kw)
939
939
940 def begin_recursive(*args, **kw):
940 def begin_recursive(*args, **kw):
941 return the_coverage.begin_recursive(*args, **kw)
941 return the_coverage.begin_recursive(*args, **kw)
942
942
943 def end_recursive(*args, **kw):
943 def end_recursive(*args, **kw):
944 return the_coverage.end_recursive(*args, **kw)
944 return the_coverage.end_recursive(*args, **kw)
945
945
946 def exclude(*args, **kw):
946 def exclude(*args, **kw):
947 return the_coverage.exclude(*args, **kw)
947 return the_coverage.exclude(*args, **kw)
948
948
949 def analysis(*args, **kw):
949 def analysis(*args, **kw):
950 return the_coverage.analysis(*args, **kw)
950 return the_coverage.analysis(*args, **kw)
951
951
952 def analysis2(*args, **kw):
952 def analysis2(*args, **kw):
953 return the_coverage.analysis2(*args, **kw)
953 return the_coverage.analysis2(*args, **kw)
954
954
955 def report(*args, **kw):
955 def report(*args, **kw):
956 return the_coverage.report(*args, **kw)
956 return the_coverage.report(*args, **kw)
957
957
958 def annotate(*args, **kw):
958 def annotate(*args, **kw):
959 return the_coverage.annotate(*args, **kw)
959 return the_coverage.annotate(*args, **kw)
960
960
961 def annotate_file(*args, **kw):
961 def annotate_file(*args, **kw):
962 return the_coverage.annotate_file(*args, **kw)
962 return the_coverage.annotate_file(*args, **kw)
963
963
964 # Save coverage data when Python exits. (The atexit module wasn't
964 # Save coverage data when Python exits. (The atexit module wasn't
@@ -1033,7 +1033,7 b" if __name__ == '__main__':"
1033 # Thanks, Allen.
1033 # Thanks, Allen.
1034 #
1034 #
1035 # 2005-12-02 NMB Call threading.settrace so that all threads are measured.
1035 # 2005-12-02 NMB Call threading.settrace so that all threads are measured.
1036 # Thanks Martin Fuzzey. Add a file argument to report so that reports can be
1036 # Thanks Martin Fuzzey. Add a file argument to report so that reports can be
1037 # captured to a different destination.
1037 # captured to a different destination.
1038 #
1038 #
1039 # 2005-12-03 NMB coverage.py can now measure itself.
1039 # 2005-12-03 NMB coverage.py can now measure itself.
@@ -541,7 +541,7 b' def run_tests(tests):'
541 fp = os.fdopen(options.child, 'w')
541 fp = os.fdopen(options.child, 'w')
542 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
542 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
543 for s in skips:
543 for s in skips:
544 fp.write("%s %s\n" % s)
544 fp.write("%s %s\n" % s)
545 fp.close()
545 fp.close()
546 else:
546 else:
547 print
547 print
General Comments 0
You need to be logged in to leave comments. Login now