This file is indexed.

/usr/lib/python2.7/dist-packages/vamos/selection.py is in undertaker 1.6-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
 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"""vamos - common auxiliary functionality"""

# Copyright (C) 2011-2012 Christian Dietrich <christian.dietrich@informatik.uni-erlangen.de>
# Copyright (C) 2011 Reinhard Tartler <tartler@informatik.uni-erlangen.de>
# Copyright (C) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
#
# 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 copy


def unique(seq):
    # order preserving
    noDupes = []
    _ = [noDupes.append(i) for i in seq if not noDupes.count(i)]
    return noDupes

class Selection:
    """A selection is a selection of symbols (derived from kconfig features). """

    def __init__(self, other_selection = None):
        """A selection can be empty, or can be copied from another
        selection. So this is somewhat like a copy constructor in c++.

        other_selection == None: empty selection
        other_selection == [{},{}]: selection from tuple
        other_selection == Selection(..): copy selection from other selection"""

        # expr == (SYMBOL || SYMBOL) && (SYMBOL || SYMBOL)
        # inner sets: alternatives
        # outer list: conjugations

        self.expr = []

        # All mentioned symbols in this selection
        self.symbols = set([])

        if other_selection:
            # Copy the other expression
            if type(other_selection) == list:
                self.expr = copy.deepcopy(other_selection)
            else:
                self.expr = copy.deepcopy(other_selection.expr)

        for or_expr in self.expr:
            for symbol in or_expr:
                self.symbols.add(symbol[0])

    def push_down(self):
        """Add a new level of or_expressions to the conjugation"""
        self.expr.append([])


    def add_alternative(self, alternative, value):
        """Add an alternative to the current "top of stack" or expression"""
        self.expr[-1].append((alternative, value))
        self.symbols.add(alternative)


    def feature_in_selection(self, feature):
        """ Tests if feature ({,_MODULE}) is already in this selection"""
        return feature in self.symbols

    def __len__(self):
        return len(self.expr)

    def __str__(self):
        """Format the selection to a (normalized) propositional formula
        (return-type: string)"""
        or_exprs = []
        for or_expr in self.expr:
            if len(or_expr) == 0:
                continue
            features = sorted(["%s=%s" % x for x in or_expr])
            if len(or_expr) == 1:
                or_exprs.append(features[0])
            else:
                or_exprs.append("(" + " || ".join(features) + ")")

        if len(or_exprs) > 0:
            return " && ".join(sorted(or_exprs))
        else:
            return ""

    __repr__ = __str__

    def __hash__(self):
        return hash(str(self))

    def __eq__(self, other):
        return str(self) == str(other)

    def to_dict(self):
        ret = {}
        for or_expr in self.expr:
            for f in or_expr:
                ret[f[0]] = f[1]
        return ret

    def better_than(self, other_selection):
        """One Selection is better than another if it is a subset of
        the other (and if it is shorter)"""
        if len(self.expr) < len(other_selection.expr):
            # When our expression is shorter we can test if our
            # expression is a subset of the other expression

            # This means all our expressions are within the other
            # expression
            for or_expr in self.expr:
                within = False
                for or_expr_1 in other_selection.expr:
                    if set(or_expr_1) == set(or_expr):
                        within = True
                if within == False:
                    return False
            return True
        else:
            return False


    def merge(self, other):
        """Expressions can be merged into one selection if they differ
        only in or_expression"""
        if len(self.expr) != len(other.expr):
            return None

        new_expr = []
        differences = 0
        different_or_expr = []

        for or_expr in self.expr:
            within = False
            for or_expr_1 in other.expr:
                if set(or_expr_1) == set(or_expr):
                    new_expr.append(or_expr)
                    within = True
            if not within:
                differences += 1
                different_or_expr = unique(different_or_expr + or_expr)
            if differences > 1:
                return None


        for or_expr in other.expr:
            within = False
            for or_expr_1 in self.expr:
                if set(or_expr_1) == set(or_expr):
                    within = True
            if not within:
                different_or_expr = unique(different_or_expr + or_expr)

        new_expr.append(different_or_expr)

        return Selection(new_expr)