This file is indexed.

/usr/lib/python2.7/dist-packages/vtk/util/vtkVariant.py is in python-vtk6 6.3.0+dfsg1-11build1.

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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
"""
Utility functions to mimic the template support functions for vtkVariant
"""

import vtk

_variant_type_map = {
    'void' : vtk.VTK_VOID,
    'char' : vtk.VTK_CHAR,
    'unsigned char' : vtk.VTK_UNSIGNED_CHAR,
    'signed char' : vtk.VTK_SIGNED_CHAR,
    'short' : vtk.VTK_SHORT,
    'unsigned short' : vtk.VTK_UNSIGNED_SHORT,
    'int' : vtk.VTK_INT,
    'unsigned int' : vtk.VTK_UNSIGNED_INT,
    'long' : vtk.VTK_LONG,
    'unsigned long' : vtk.VTK_UNSIGNED_LONG,
    'long long' : vtk.VTK_LONG_LONG,
    'unsigned long long' : vtk.VTK_UNSIGNED_LONG_LONG,
    '__int64' : vtk.VTK___INT64,
    'unsigned __int64' : vtk.VTK_UNSIGNED___INT64,
    'float' : vtk.VTK_FLOAT,
    'double' : vtk.VTK_DOUBLE,
    'string' : vtk.VTK_STRING,
    'unicode string' : vtk.VTK_UNICODE_STRING,
    'vtkObjectBase' : vtk.VTK_OBJECT,
    'vtkObject' : vtk.VTK_OBJECT,
}

_variant_method_map = {
    vtk.VTK_VOID : '',
    vtk.VTK_CHAR : 'ToChar',
    vtk.VTK_UNSIGNED_CHAR : 'ToUnsignedChar',
    vtk.VTK_SIGNED_CHAR : 'ToSignedChar',
    vtk.VTK_SHORT : 'ToShort',
    vtk.VTK_UNSIGNED_SHORT : 'ToUnsignedShort',
    vtk.VTK_INT : 'ToInt',
    vtk.VTK_UNSIGNED_INT : 'ToUnsignedInt',
    vtk.VTK_LONG : 'ToLong',
    vtk.VTK_UNSIGNED_LONG : 'ToUnsignedLong',
    vtk.VTK_LONG_LONG : 'ToLongLong',
    vtk.VTK_UNSIGNED_LONG_LONG : 'ToUnsignedLongLong',
    vtk.VTK___INT64 : 'To__Int64',
    vtk.VTK_UNSIGNED___INT64 : 'ToUnsigned__Int64',
    vtk.VTK_FLOAT : 'ToFloat',
    vtk.VTK_DOUBLE : 'ToDouble',
    vtk.VTK_STRING : 'ToString',
    vtk.VTK_UNICODE_STRING : 'ToUnicodeString',
    vtk.VTK_OBJECT : 'ToVTKObject',
}

_variant_check_map = {
    vtk.VTK_VOID : 'IsValid',
    vtk.VTK_CHAR : 'IsChar',
    vtk.VTK_UNSIGNED_CHAR : 'IsUnsignedChar',
    vtk.VTK_SIGNED_CHAR : 'IsSignedChar',
    vtk.VTK_SHORT : 'IsShort',
    vtk.VTK_UNSIGNED_SHORT : 'IsUnsignedShort',
    vtk.VTK_INT : 'IsInt',
    vtk.VTK_UNSIGNED_INT : 'IsUnsignedInt',
    vtk.VTK_LONG : 'IsLong',
    vtk.VTK_UNSIGNED_LONG : 'IsUnsignedLong',
    vtk.VTK_LONG_LONG : 'IsLongLong',
    vtk.VTK_UNSIGNED_LONG_LONG : 'IsUnsignedLongLong',
    vtk.VTK___INT64 : 'Is__Int64',
    vtk.VTK_UNSIGNED___INT64 : 'IsUnsigned__Int64',
    vtk.VTK_FLOAT : 'IsFloat',
    vtk.VTK_DOUBLE : 'IsDouble',
    vtk.VTK_STRING : 'IsString',
    vtk.VTK_UNICODE_STRING : 'IsUnicodeString',
    vtk.VTK_OBJECT : 'IsVTKObject',
}


def vtkVariantCreate(v, t):
    """
    Create a vtkVariant of the specified type, where the type is in the
    following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' or 'unicode string' for strings.  You can also use an
    integer VTK type constant for the type.
    """
    if not issubclass(type(t), int):
        t = _variant_type_map[t]

    return vtk.vtkVariant(v, t)


def vtkVariantExtract(v, t=None):
    """
    Extract the specified value type from the vtkVariant, where the type is
    in the following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' or 'unicode string' for strings.  You can also use an
    integer VTK type constant for the type.  Set the type to 'None" to
    extract the value in its native type.
    """
    v = vtk.vtkVariant(v)

    if t == None:
        t = v.GetType()
    elif not issubclass(type(t), int):
        t = _variant_type_map[t]

    if getattr(v, _variant_check_map[t])():
        return getattr(v, _variant_method_map[t])()
    else:
        return None


def vtkVariantCast(v, t):
    """
    Cast the vtkVariant to the specified value type, where the type is
    in the following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' or 'unicode string' for strings.  You can also use an
    integer VTK type constant for the type.
    """
    if not issubclass(type(t), int):
        t = _variant_type_map[t]

    v = vtk.vtkVariant(v, t)

    if v.IsValid():
        return getattr(v, _variant_method_map[t])()
    else:
        return None


def vtkVariantStrictWeakOrder(s1, s2):
    """
    Compare variants by type first, and then by value.  The return values
    are -1, 0, 1 like the python cmp() method, for compatibility with the
    python list sort() method.  This is in contrast with the C++ version,
    which returns true or false.
    """
    s1 = vtk.vtkVariant(s1)
    s2 = vtk.vtkVariant(s2)

    t1 = s1.GetType()
    t2 = s2.GetType()

    # check based on type
    if t1 != t2:
        return cmp(t1,t2)

    v1 = s1.IsValid()
    v2 = s2.IsValid()

    # check based on validity
    if (not v1) and (not v2):
        return 0
    elif v1 != v2:
        return cmp(v1,v2)

    # extract and compare the values
    r1 = getattr(s1, _variant_method_map[t1])()
    r2 = getattr(s2, _variant_method_map[t2])()

    # compare vtk objects by classname
    if t1 == vtk.VTK_OBJECT:
        return cmp(r1.GetClassName(), r2.GetClassName())

    return cmp(r1, r2)


def vtkVariantStrictEquality(s1, s2):
    """
    Check two variants for strict equality of type and value.
    """
    s1 = vtk.vtkVariant(s1)
    s2 = vtk.vtkVariant(s2)

    t1 = s1.GetType()
    t2 = s2.GetType()

    # check based on type
    if t1 != t2:
        return False

    v1 = s1.IsValid()
    v2 = s2.IsValid()

    # check based on validity
    if (not v1) and (not v2):
        return True
    elif v1 != v2:
        return False

    # extract and compare the values
    r1 = getattr(s1, _variant_method_map[t1])()
    r2 = getattr(s2, _variant_method_map[t2])()

    return (r1 == r2)


def vtkVariantLessThan(s1, s2):
    """
    Return true if s1 < s2.  This isn't very useful in Python.
    """
    return (vtk.vtkVariant(s1) < vtk.vtkVariant(s2))


def vtkVariantEqual(s1, s2):
    """
    Return true if s1 == s2.  This isn't very useful in Python.
    """
    return (vtk.vtkVariant(s1) == vtk.vtkVariant(s2))