This file is indexed.

/usr/lib/python3/dist-packages/autopilot/_config.py is in python3-autopilot 1.5.1+16.04.20160412-0ubuntu1.

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
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2014 Canonical
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import collections.abc


_test_config_string = ""


def set_configuration_string(config_string):
    """Set the test configuration string.

    This must be a text string that specifies the test configuration. The
    string is a comma separated list of 'key=value' or 'key' tokens.

    """
    global _test_config_string
    _test_config_string = config_string


def get_test_configuration():
    """Get the test configuration dictionary.

    Tests can be configured from the command line when the ``autopilot`` tool
    is invoked. Typical use cases involve configuring the test suite to use
    a particular binary (perhaps a locally built binary or one installed to
    the system), or configuring which external services are faked.

    This dictionary is populated from the ``--config`` option to the
    ``autopilot run`` command. For example:

    ``autopilot run --config use_local some.test.id``

    Will result in a dictionary where the key ``use_local`` is present, and
    evaluates to true, e.g.-::

        from autopilot import get_test_configuration
        if get_test_configuration['use_local']: print("Using local binary")

    Values can also be specified. The following command:

    ``autopilot run --config fake_services=login some.test.id``

    ...will result in the key 'fake_services' having the value 'login'.

    Autopilot itself does nothing with the conents of this dictionary. It is
    entirely up to test authors to populate it, and to use the values as they
    see fit.

    """
    return ConfigDict(_test_config_string)


class ConfigDict(collections.abc.Mapping):

    def __init__(self, config_string):
        self._data = {}
        config_items = (item for item in config_string.split(',') if item)
        for item in config_items:
            parts = item.split('=', 1)
            safe_key = parts[0].lstrip()
            if len(parts) == 1 and safe_key != '':
                self._data[safe_key] = '1'
            elif len(parts) == 2 and safe_key != '':
                self._data[safe_key] = parts[1]
            else:
                raise ValueError(
                    "Invalid configuration string '{}'".format(config_string)
                )

    def __getitem__(self, key):
        return self._data.__getitem__(key)

    def __iter__(self):
        return self._data.__iter__()

    def __len__(self):
        return self._data.__len__()