This file is indexed.

/usr/lib/python2.7/dist-packages/oslo_reports/views/json/generic.py is in python-oslo.reports 1.7.0-2.

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
# Copyright 2013 Red Hat, Inc.
#
#    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.

"""Provides generic JSON views

This modules defines several basic views for serializing
data to JSON.  Submodels that have already been serialized
as JSON may have their string values marked with `__is_json__
= True` using :class:`oslo_reports._utils.StringWithAttrs`
(each of the classes within this module does this automatically,
and non-naive serializers check for this attribute and handle
such strings specially)
"""

import copy

from oslo_serialization import jsonutils as json

from oslo_reports import _utils as utils


class BasicKeyValueView(object):
    """A Basic Key-Value JSON View

    This view performs a naive serialization of a model
    into JSON by simply calling :func:`json.dumps` on the model
    """

    def __call__(self, model):
        res = utils.StringWithAttrs(json.dumps(model.data, sort_keys=True))
        res.__is_json__ = True
        return res


class KeyValueView(object):
    """A Key-Value JSON View

    This view performs advanced serialization to a model
    into JSON.  It does so by first checking all values to
    see if they are marked as JSON.  If so, they are deserialized
    using :func:`json.loads`.  Then, the copy of the model with all
    JSON deserialized is reserialized into proper nested JSON using
    :func:`json.dumps`.
    """

    def __call__(self, model):
        # this part deals with subviews that were already serialized
        cpy = copy.deepcopy(model)
        for key in model.keys():
            if getattr(model[key], '__is_json__', False):
                cpy[key] = json.loads(model[key])

        res = utils.StringWithAttrs(json.dumps(cpy.data, sort_keys=True))
        res.__is_json__ = True
        return res