This file is indexed.

/usr/lib/python2.7/dist-packages/DistUtilsExtra/command/pylint.py is in python-distutils-extra 2.41ubuntu1.

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
81
82
83
84
85
86
87
88
89
90
91
92
# DistUtilsExtra.command.pylint - DistUtilsExtra command to call pylint
#
# Author: Rodney Dawes <rodney.dawes@canonical.com>
# Copyright 2009 Canonical Ltd.

"""DistUtilsExtra.command.pylint

Implements the DistUtilsExtra 'pylint' command.
"""

import os
import subprocess

from distutils.core import Command


class pylint (Command):
    """Command to run pylint and tests on a module."""

    description = "integrate pylint checks"

    user_options = [("config-file=", None,
                     "pylint config file to use"),
                    ("exclude-files=", None,
                     "list of files to exclude from lint checks"),
                    ("lint-files=", None,
                     "list of modules or packages to run lint checks on")
                   ]

    def initialize_options (self):
        self.config_file = None
        self.exclude_files = None
        self.lint_files = None

    def finalize_options (self):
        if self.config_file is None:
            self.config_file = ""
        if self.exclude_files is None:
            self.exclude_files = "[]"
        if self.lint_files is None:
            self.lint_files = "[" + self.__find_files() + "]"

    def run (self):
        pylint_args = ["--output-format=parseable",
                       "--include-ids=yes"]

        if self.config_file:
            pylint_args.append("--rcfile=" + self.config_file)

        for file in eval(self.lint_files):
            pylint_args.append(file)

        p = subprocess.Popen(["pylint"] + pylint_args,
                             bufsize=4096, stdout=subprocess.PIPE)
        notices = p.stdout

        output = "".join(notices.readlines())
        if output != "":
            print("== Pylint notices ==")
            print(self.__group_lines_by_file(output))

    def __group_lines_by_file(self, input):
        """Format file:line:message output as lines grouped by file."""
        outputs = []
        filename = ""
        excludes = eval(self.exclude_files)
        for line in input.splitlines():
            current = line.split(":", 3)
            if line.startswith("    "):
                outputs.append("    " + current[0] + "")
            elif line.startswith("build/") or current[0] in excludes or \
                    len(current) < 3:
                pass
            elif filename == current[0]:
                outputs.append("    " + current[1] + ": " + current[2])
            elif filename != current[0]:
                filename = current[0]
                outputs.append("")
                outputs.append(filename + ":")
                outputs.append("    " + current[1] + ": " + current[2])

        return "\n".join(outputs)

    def __find_files(self):
        """Find all Python files under the current tree."""
        pyfiles = []
        for root, dirs, files in os.walk(os.getcwd(), topdown=False):
            for file in files:
                if file.endswith(".py"):
                    pyfiles.append("'" + os.path.join(root, file) + "'")
        pyfiles.sort()
        return ",".join(pyfiles)