This file is indexed.

/usr/lib/python3/dist-packages/shredder/cmdline.py is in rmlint-gui 2.6.1-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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python
# encoding: utf-8

"""Commandline parsing facility for Shredder.

Produces an option dict that can be used by shredder.application.
Some options are processed immediately however.
"""

# Stdlib:
import os
import sys
import logging

# External:
from gi.repository import Gio
from gi.repository import GLib


def show_version():
    """Print the version as shown by `rmlint --version`"""
    proc = Gio.Subprocess.new(
        ['rmlint', '--version'],
        Gio.SubprocessFlags.STDERR_PIPE
    )
    *_, data = proc.communicate_utf8()

    # Shredder version is always the same as rmlint.
    # So, let's just replace `rmlint` with `Shredder` :-)
    print(data.replace('rmlint', 'Shredder', 1), end='')
    sys.exit(-1)


def adjust_loglevel(root_logger, count):
    """Convert a -v count to a python loglevel."""
    count = max(0, min(4, count))

    root_logger.setLevel({
        0: logging.CRITICAL,
        1: logging.ERROR,
        2: logging.WARNING,
        3: logging.INFO,
        4: logging.DEBUG,
    }[count])


def parse_arguments(root_logger):
    """Parse the cmdline options using GOption."""
    sys.argv[0] = 'shredder'
    parser = GLib.option.OptionParser(
        "PATHS ...",
        description="A gui frontend to rmlint.",
        option_list=[
            GLib.option.make_option(
                "--add-location", "-a",
                type="filename",
                action="append",
                dest="locations",
                help="Add locations to locations view."
            ),
            GLib.option.make_option(
                "--scan", "-s",
                type="filename",
                action="append",
                dest="untagged",
                help="Add location to scan (as untagged path)."
            ),
            GLib.option.make_option(
                "--scan-tagged", "-S",
                type="filename",
                action="append",
                dest="tagged",
                help="Add location to scan (as tagged path)."
            ),
            GLib.option.make_option(
                "--load-script", "-l",
                type="filename",
                action="store",
                dest="script",
                help="Show `script` in editor view."
            ),
            GLib.option.make_option(
                "--verbose", "-v",
                action="count",
                dest='more_verbosity',
                help="Be more verbose."
            ),
            GLib.option.make_option(
                "--less-verbose", "-V",
                action="count",
                dest='less_verbosity',
                help="Be less verbose."
            ),
            GLib.option.make_option(
                "--show-settings", "-c",
                action="store_true",
                dest='show_settings',
                help="Show the settings view."
            ),
            GLib.option.make_option(
                "--version", "",
                action="store_true",
                dest="show_version",
                help="Show the version of Shredder."
            ),
        ]
    )

    try:
        parser.parse_args()
    except GLib.Error as err:
        root_logger.error(str(err))
        return None

    vals = parser.values
    if parser.values.show_version:
        show_version()

    adjust_loglevel(
        root_logger,
        (vals.more_verbosity or 0) +
        (vals.less_verbosity or 0) +
        4  # Default loglevel: info.
    )

    # Check paths to be valid:
    paths = (vals.tagged or []) + (vals.untagged or []) + [vals.script]
    for path in (path for path in paths if path):
        if not os.path.exists(path):
            root_logger.error('`%s` does not exist.', path)
            sys.exit(-1)

    return vals


if __name__ == '__main__':
    LOGGER = logging.getLogger('test-cmdline')
    print(parse_arguments(LOGGER))