This file is indexed.

/usr/lib/python3/dist-packages/plainbox/impl/unit/manifest.py is in python3-plainbox 0.25-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
# This file is part of Checkbox.
#
# Copyright 2012-2015 Canonical Ltd.
# Written by:
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox 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 Checkbox.  If not, see <http://www.gnu.org/licenses/>.

""" Manifest Entry Unit. """
import logging

from plainbox.impl.symbol import SymbolDef
from plainbox.impl.unit.unit_with_id import UnitWithId
from plainbox.impl.unit.validators import CorrectFieldValueValidator
from plainbox.impl.unit.validators import PresentFieldValidator
from plainbox.impl.unit.validators import TemplateVariantFieldValidator
from plainbox.impl.unit.validators import TranslatableFieldValidator
from plainbox.impl.unit.validators import UntranslatableFieldValidator

logger = logging.getLogger("plainbox.unit.manifest")


__all__ = ('ManifestEntryUnit', )


class ManifestEntryUnit(UnitWithId):

    """
    Unit representing a single entry in a hardware specification manifest.

    This unit can be used to describe a single quality (either qualitative or
    quantitative) of a device under test. Manifest data is provided externally
    and cannot or should not be detected by the code running on the device.
    """

    @property
    def name(self):
        """ Name of the entry. """
        return self.get_record_value('name')

    def tr_name(self):
        """ Name of the entry (translated). """
        return self.get_translated_record_value('name')

    @property
    def value_type(self):
        """
        Type of value of the entry.

        This field defines the kind of entry we wish to describe. Currently
        only ``"natural"`` and ``"bool"`` are supported. This value is loaded
        from the ``value-type`` field.
        """
        return self.get_record_value('value-type')

    @property
    def value_unit(self):
        """
        Type of unit the value is measured in.

        Typically this will be the unit in which the quantity is measured, e.g.
        "Mbit", "GB". This value is loaded from the ``value-unit`` field.
        """
        return self.get_record_value('value-unit')

    @property
    def resource_key(self):
        """
        Name of this manifest entry when presented as a resource.

        This value is loaded from the ``resource-key`` field. It defaults to
        the partial identifier of the unit.
        """
        return self.get_record_value('resource-key', self.partial_id)

    class Meta:

        name = 'manifest entry'

        class fields(SymbolDef):

            """ Symbols for each field that a TestPlan can have. """

            name = 'name'
            value_type = 'value-type'
            value_unit = 'value-unit'
            resource_key = 'resource-key'

        field_validators = {
            fields.name: [
                TranslatableFieldValidator,
                TemplateVariantFieldValidator,
                PresentFieldValidator,
            ],
            fields.value_type: [
                UntranslatableFieldValidator,
                PresentFieldValidator(),
                CorrectFieldValueValidator(
                    lambda value_type: value_type in ('bool', 'natural')),
            ],
            fields.value_unit: [
                # OPTIONAL
            ],
            fields.resource_key: [
                UntranslatableFieldValidator,
            ]
        }