This file is indexed.

/usr/lib/python3/dist-packages/designateclient/functionaltests/models.py is in python3-designateclient 2.9.0-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
95
96
"""
Copyright 2015 Rackspace

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import six
from tempest.lib.cli import output_parser


class Model(object):

    def __str__(self):
        return str(self.__dict__)


class FieldValueModel(Model):
    """This converts cli output from messy lists/dicts to neat attributes."""

    def __init__(self, out):
        """This parses output with fields and values like:

            +----------------+------------------------------+
            | Field          | Value                        |
            +----------------+------------------------------+
            | action         | CREATE                       |
            | created_at     | 2015-08-20T17:22:17.000000   |
            | description    | None                         |
            +----------------+------------------------------+

        These are then accessible as:

            model.action
            model.created_at
            model.description

        """
        table = output_parser.table(out)

        # Because the output_parser handles Values with multiple lines
        # in additional Field/Value pairs with Field name '', the following
        # code is necessary to aggregate Values.
        #
        # The list of Field/Value pairs is in-order, so we can append Value
        # continuation to the previously seen Field, with a newline separator.
        value_lines = []
        prev_field = None
        for field, value in table['values']:
            if field == '':
                value_lines.append(value)
                setattr(self, prev_field, '\n'.join(value_lines))
            else:
                setattr(self, field, value)
                prev_field = field
                value_lines = [value]


class ListEntryModel(Model):

    def __init__(self, fields, values):
        for k, v in six.moves.zip(fields, values):
            setattr(self, k, v)


class ListModel(Model, list):

    def __init__(self, out):
        """This parses an output table with any number of headers, and any
        number of entries:

            +--------------------------------------+----------+---------+
            | id                                   | name     | type    |
            +--------------------------------------+----------+---------+
            | e658a875-1024-4f88-a347-e5b244ec5a10 | aaa.com. | PRIMARY |
            +--------------------------------------+----------+---------+
            | 98d1fb5f-2954-448e-988e-6f1df0f24c52 | bbb.com. | PRIMARY |
            +--------------------------------------+----------+---------+

        These are then accessible as:

            model[0].name == 'aaa.com.'
            model[1].name == 'bbb.com.'

        """
        table = output_parser.table(out)
        for entry in table['values']:
            self.append(ListEntryModel(table['headers'], entry))