This file is indexed.

/usr/lib/python2.7/dist-packages/nosexcover/nosexcover.py is in python-nosexcover 1.0.11-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Companion to nose.plugins.cover. Enable by adding --with-xcoverage to your
arguments. A Cobertura-style XML file, honoring the options you pass to
--with-coverage, will be generated in coverage.xml"""

import logging
import sys
try:
    # Python 2
    from StringIO import StringIO
except ImportError:
    # Python 3
    from io import StringIO

from nose.plugins import cover, Plugin
log = logging.getLogger('nose.plugins.xcover')


class XCoverage(cover.Coverage):
    """
    Add Cobertura-style XML coverage reports
    to the built-in nose.plugins.cover plugin.
    """

    def options(self, parser, env):
        """
        Add options to command line.
        """
        Plugin.options(self, parser, env)
        parser.add_option('--xcoverage-file', action='store',
                          default=env.get('NOSE_XCOVER_FILE', 'coverage.xml'),
                          dest='xcoverage_file',
                          metavar="FILE",
                          help='Path to xml coverage report.'
                          'Default is coverage.xml in the working directory. '
                          '[NOSE_XCOVERAGE_FILE]')
        parser.add_option('--xcoverage-to-stdout', action='store',
                          default=env.get('NOSE_XCOVER_TO_STDOUT', True),
                          dest='xcoverage_to_stdout',
                          help='Print coverage information to stdout.'
                          'Default is True (output coverage information to stdout). '
                          '[NOSE_XCOVER_TO_STDOUT]')
        
    def configure(self, options, config):
        coverage_on = options.enable_plugin_coverage
        xcoverage_on = options.enable_plugin_xcoverage
        if xcoverage_on and coverage_on:
            error_msg = """You can not use both --with-xcover and --with-coverage. Using --with-xcover implies --with-coverage"""
            log.error(error_msg)
            raise TypeError(error_msg + "\n Please check if you have a default entry in .noserc or nose.cfg or setup.cfg alike configuration file")

        cover.old_log = cover.log
        cover.log = log
        super(XCoverage, self).configure(options, config)
        cover.log = cover.old_log

        self.xcoverageFile = options.xcoverage_file
        
        to_stdout = str(options.xcoverage_to_stdout)
        self.xcoverageToStdout = False if '0' in to_stdout or 'false' in to_stdout.lower() else True

    def report(self, stream):
        """
        Output code coverage report.
        """
        if not self.xcoverageToStdout:
            # This will create a false stream where output will be ignored
            stream = StringIO()
            
        super(XCoverage, self).report(stream)
        if not hasattr(self, 'coverInstance'):
            # nose coverage plugin 1.0 and earlier
            import coverage
            self.coverInstance = coverage._the_coverage

        modules = [module
                    for name, module in sys.modules.items()
                    if self.wantModuleCoverage(name, module)]
        log.debug("Coverage report will cover modules: %s", modules)
        morfs = [m.__file__ for m in modules if hasattr(m, '__file__')]
        self.coverInstance.xml_report(morfs, outfile=self.xcoverageFile)