merge with bb://tuos/sphinx

This commit is contained in:
Georg Brandl 2011-01-04 22:20:10 +01:00
commit 9ac5f2b873

View File

@ -362,8 +362,9 @@ class coverage:
settings[o[2:]] = 1 settings[o[2:]] = 1
elif o[2:] + '=' in long_opts: elif o[2:] + '=' in long_opts:
settings[o[2:]+'='] = a settings[o[2:]+'='] = a
else: #pragma: no cover else: #pragma: no cover
pass # Can't get here, because getopt won't return anything unknown. # Can't get here, because getopt won't return anything unknown.
pass
if settings.get('help'): if settings.get('help'):
help_fn() help_fn()
@ -645,20 +646,23 @@ class coverage:
def find_docstring_pass_pair(self, tree, spots): def find_docstring_pass_pair(self, tree, spots):
for i in range(1, len(tree)): for i in range(1, len(tree)):
if self.is_string_constant(tree[i]) and self.is_pass_stmt(tree[i+1]): if (self.is_string_constant(tree[i])
and self.is_pass_stmt(tree[i+1])):
first_line = self.first_line_of_tree(tree[i]) first_line = self.first_line_of_tree(tree[i])
last_line = self.last_line_of_tree(tree[i+1]) last_line = self.last_line_of_tree(tree[i+1])
self.record_multiline(spots, first_line, last_line) self.record_multiline(spots, first_line, last_line)
def is_string_constant(self, tree): def is_string_constant(self, tree):
try: try:
return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.expr_stmt return (tree[0] == symbol.stmt
and tree[1][1][1][0] == symbol.expr_stmt)
except: except:
return False return False
def is_pass_stmt(self, tree): def is_pass_stmt(self, tree):
try: try:
return tree[0] == symbol.stmt and tree[1][1][1][0] == symbol.pass_stmt return (tree[0] == symbol.stmt
and tree[1][1][1][0] == symbol.pass_stmt)
except: except:
return False return False
@ -761,7 +765,7 @@ class coverage:
pairs = [] pairs = []
while i < len(statements) and j < len(lines): while i < len(statements) and j < len(lines):
if statements[i] == lines[j]: if statements[i] == lines[j]:
if start == None: if start is None:
start = lines[j] start = lines[j]
end = lines[j] end = lines[j]
j = j + 1 j = j + 1
@ -831,7 +835,8 @@ class coverage:
def morf_name_compare(self, x, y): def morf_name_compare(self, x, y):
return cmp(self.morf_name(x), self.morf_name(y)) return cmp(self.morf_name(x), self.morf_name(y))
def report(self, morfs, show_missing=1, ignore_errors=0, file=None, omit_prefixes=[]): def report(self, morfs, show_missing=1, ignore_errors=0, file=None,
omit_prefixes=[]):
if not isinstance(morfs, types.ListType): if not isinstance(morfs, types.ListType):
morfs = [morfs] morfs = [morfs]
# On windows, the shell doesn't expand wildcards. Do it here. # On windows, the shell doesn't expand wildcards. Do it here.
@ -898,19 +903,23 @@ class coverage:
blank_re = re.compile(r"\s*(#|$)") blank_re = re.compile(r"\s*(#|$)")
else_re = re.compile(r"\s*else\s*:\s*(#|$)") else_re = re.compile(r"\s*else\s*:\s*(#|$)")
def annotate(self, morfs, directory=None, ignore_errors=0, omit_prefixes=[]): def annotate(self, morfs, directory=None, ignore_errors=0,
omit_prefixes=[]):
morfs = self.filter_by_prefix(morfs, omit_prefixes) morfs = self.filter_by_prefix(morfs, omit_prefixes)
for morf in morfs: for morf in morfs:
try: try:
filename, statements, excluded, missing, _ = self.analysis2(morf) (filename, statements, excluded,
self.annotate_file(filename, statements, excluded, missing, directory) missing, _) = self.analysis2(morf)
self.annotate_file(filename, statements, excluded, missing,
directory)
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except:
if not ignore_errors: if not ignore_errors:
raise raise
def annotate_file(self, filename, statements, excluded, missing, directory=None): def annotate_file(self, filename, statements, excluded, missing,
directory=None):
source = open(filename, 'r') source = open(filename, 'r')
if directory: if directory:
dest_file = os.path.join(directory, dest_file = os.path.join(directory,