This file is indexed.

/usr/lib/python2.7/dist-packages/dicom/multival.py is in python-dicom 0.9.9-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
# multival.py
"""Code for multi-value data elements values, or any list of items that
must all be the same type.
"""
# Copyright (c) 2009-2012 Darcy Mason
# This file is part of pydicom, relased under an MIT-style license.
#    See the file license.txt included with this distribution, also
#    available at http://pydicom.googlecode.com
#


class MultiValue(list):
    """Class to hold any multi-valued DICOM value, or any list of items
    that are all of the same type.

    This class enforces that any items added to the list are of the correct type,
    by calling the constructor on any items that are added. Therefore, the
    constructor must behave nicely if passed an object that is already its type.
    The constructor should raise TypeError if the item cannot be converted.

    Note, however, that DS and IS types can be a blank string '' rather
    than an instance of their classes.
    """

    def __init__(self, type_constructor, iterable):
        """Initialize the list of values

        :param type_constructor: a constructor for the required type for all list
                           items. Could be the class, or a factory function.
                           For DICOM mult-value data elements, this will be the
                           class or type corresponding to the VR.
        :param iterable: an iterable (e.g. list, tuple) of items to initialize
                        the MultiValue list
        """
        from dicom.valuerep import DSfloat, DSdecimal, IS
        self.type_constructor = type_constructor
        if isinstance(type_constructor, (DSfloat, IS, DSdecimal)):
            converted_list = [type_constructor(x) if x != ''
                              else x for x in iterable]
        else:
            converted_list = [type_constructor(x) for x in iterable]
        super(MultiValue, self).__init__(converted_list)

    def append(self, val):
        super(MultiValue, self).append(self.type_constructor(val))

    def extend(self, list_of_vals):
        super(MultiValue, self).extend((self.type_constructor(x) for x in list_of_vals))

    def insert(self, position, val):
        super(MultiValue, self).insert(position, self.type_constructor(val))

    def __setitem__(self, i, val):
        """Set an item of the list, making sure it is of the right VR type"""
        if isinstance(i, slice):
            val = [self.type_constructor(x) for x in val]
        else:
            val = self.type_constructor(val)
        super(MultiValue, self).__setitem__(i, val)

    def __str__(self):
        lines = [str(x) for x in self]
        return "['" + "', '".join(lines) + "']"
    __repr__ = __str__