This file is indexed.

/usr/lib/python3/dist-packages/devscripts/test/test_pylint.py is in devscripts 2.16.2ubuntu3.

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
# test_pylint.py - Run pylint in errors-only mode.
#
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

import re
import subprocess

import setup
from devscripts.test import unittest

WHITELIST = [re.compile(': %s$' % x) for x in (
    # Wildcard import:
    r"No name '\w+Error' in module 'launchpadlib\.errors'",
    # https://www.logilab.org/ticket/51250:
    r"Module 'hashlib' has no '(md5|sha(1|224|256|384|512))' member",
    # mox:
    r"Instance of '.+' has no '(WithSideEffects|MultipleTimes|AndReturn)' "
    r"member",
)]


class PylintTestCase(unittest.TestCase):
    def test_pylint(self):
        "Test: Run pylint on Python source code"
        files = ['devscripts']
        for script in setup.scripts:
            f = open(script, 'r', encoding='utf-8')
            if 'python' in f.readline():
                files.append(script)
            f.close()
        cmd = ['pylint', '--rcfile=devscripts/test/pylint.conf', '-E',
               '--include-ids=y', '--'] + files
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE, close_fds=True)

        out, err = process.communicate()
        if err != '':
            raise unittest.SkipTest('pylint crashed :/')

        filtered_out = []
        detected_in = ''
        # pylint: disable=E1103
        for line in out.splitlines():
            # pylint: enable=E1103
            if line.startswith('************* '):
                detected_in = line
                continue

            for reg_exp in WHITELIST:
                if reg_exp.search(line):
                    break
            else:
                filtered_out.append(detected_in)
                filtered_out.append(line)

        self.assertEqual(filtered_out, [],
                         "pylint found errors.\n"
                         "Filtered Output:\n" + '\n'.join(filtered_out))