This file is indexed.

/usr/lib/python3/dist-packages/pyutilib/misc/cross.py is in python3-pyutilib 5.3.5-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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#  _________________________________________________________________________
#
#  PyUtilib: A Python utility library.
#  Copyright (c) 2008 Sandia Corporation.
#  This software is distributed under the BSD License.
#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
#  the U.S. Government retains certain rights in this software.
#  _________________________________________________________________________


import sys
from pyutilib.misc import misc

if sys.version_info >= (3,0):
    xrange = range


def _cross_exec(set_tuple):
    """
    Function used by cross() to generate the cross-product of a tuple
    """
    resulting_set = []
    if len(set_tuple) == 1:
        for val in set_tuple[0]:
            resulting_set.append( [val] )
    else:
        tmp_set = _cross_exec(set_tuple[1:])
        for val in set_tuple[0]:
            for item in tmp_set:
                #print val, item
                resulting_set.append( [val] + item )
    return resulting_set

def cross(set_tuple):
    """
    Returns the cross-product of a tuple of values
    """
    result_set = []
    tmp_set = _cross_exec(set_tuple)
    for val in tmp_set:
        result_set.append( tuple(val) )
    return result_set

#def tmp_cross(*args):
#    ans = [[]]
#    for arg in args:
#      ans = [x+[y] for x in ans for y in arg]
#    return ans



if sys.version_info < (3,0):

    def cross_iter(*sets):
        """
        An iterator function that generates a cross product of
        a set.

        Derived from code developed by Steven Taschuk
        """
        wheels = map(iter, sets) # wheels like in an odometer
        digits = [it.next() for it in wheels]
        while True:
            yield tuple(digits[:])
            for i in xrange(len(digits)-1, -1, -1):
                try:
                    digits[i] = wheels[i].next()
                    break
                except StopIteration:
                    wheels[i] = iter(sets[i])
                    digits[i] = wheels[i].next()
            else:
                break


    def flattened_cross_iter(*sets):
        """
        An iterator function that generates a cross product of
        a set, and flattens it.
        """
        wheels = map(iter, sets) # wheels like in an odometer
        digits = [it.next() for it in wheels]
        ndigits = len(digits)
        while True:
            yield misc.flatten_tuple(tuple(digits[:]))
            for i in xrange(ndigits-1, -1, -1):
                try:
                    digits[i] = wheels[i].next()
                    break
                except StopIteration:
                    wheels[i] = iter(sets[i])
                    digits[i] = wheels[i].next()
            else:
                break


else:

    def cross_iter(*sets):
        """
        An iterator function that generates a cross product of
        a set.

        Derived from code developed by Steven Taschuk
        """
        wheels = list(map(iter, sets)) # wheels like in an odometer
        digits = [next(it) for it in wheels]
        while True:
            yield tuple(digits[:])
            for i in range(len(digits)-1, -1, -1):
                try:
                    digits[i] = next(wheels[i])
                    break
                except StopIteration:
                    wheels[i] = iter(sets[i])
                    digits[i] = next(wheels[i])
            else:
                break


    def flattened_cross_iter(*sets):
        """
        An iterator function that generates a cross product of
        a set, and flattens it.
        """
        wheels = list(map(iter, sets)) # wheels like in an odometer
        digits = [next(it) for it in wheels]
        ndigits = len(digits)
        while True:
            yield misc.flatten_tuple(tuple(digits[:]))
            for i in range(ndigits-1, -1, -1):
                try:
                    digits[i] = next(wheels[i])
                    break
                except StopIteration:
                    wheels[i] = iter(sets[i])
                    digits[i] = next(wheels[i])
            else:
                break