This file is indexed.

/usr/share/pyshared/pyth/document.py is in python-pyth 0.5.6-2build1.

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
"""
Abstract document representation
"""

class _PythBase(object):

    def __init__(self, properties={}, content=[]):
        self.properties = {}
        self.content = []
        
        for (k,v) in properties.iteritems():
            self[k] = v

        for item in content:
            self.append(item)


    def __setitem__(self, key, value):
        if key not in self.validProperties:
            raise ValueError("Invalid %s property: %s" % (self.__class__.__name__, repr(key)))

        self.properties[key] = value

    def __getitem__(self, key):
        if key not in self.validProperties:
            raise ValueError("Invalid %s property: %s" %
                             (self.__class__.__name__, repr(key)))
        return self.properties.get(key)

    def append(self, item):
        """
        Try to add an item to this element.

        If the item is of the wrong type, and if this element has a sub-type,
        then try to create such a sub-type and insert the item into that, instead.
        
        This happens recursively, so (in python-markup):
          L [ u'Foo' ]
        actually creates:
          L [ LE [ P [ T [ u'Foo' ] ] ] ]

        If that doesn't work, raise a TypeError.
        """

        okay = True
        if not isinstance(item, self.contentType):
            if hasattr(self.contentType, 'contentType'):
                try:
                    item = self.contentType(content=[item])
                except TypeError:
                    okay = False
            else:
                okay = False
                
        if not okay:
            raise TypeError("Wrong content type for %s: %s (%s)" % (
                self.__class__.__name__, repr(type(item)), repr(item)))

        self.content.append(item)



class Text(_PythBase):
    """
    Text runs are strings of text with markup properties,
    like 'bold' or 'italic' (or 'hyperlink to ...').

    They are rendered inline (not as blocks).

    They do not inherit their properties from anything.
    """

    validProperties = ('bold', 'italic', 'underline', 'url', 'sub', 'super')
    contentType = unicode

    def __repr__(self):
        return "Text('%s' %s)" % ("".join("[%s]" % r.encode("utf-8") for r in self.content), self.properties)



class Paragraph(_PythBase):
    """
    Paragraphs contain zero or more text runs.

    They cannot contain other paragraphs (but see List).

    They have no text markup properties, but may
    have rendering properties (e.g. margins)
    """

    validProperties = ()
    contentType = Text



class ListEntry(_PythBase):
    """
    A list of paragraphs representing one item in a list
    """
    validProperties = ()
    contentType = Paragraph


class List(Paragraph):
    """
    A list of paragraphs which will be rendered as a bullet list.

    A List is a Paragraph, so Lists can be nested.
    """

    validProperties = ()
    contentType = ListEntry
    


class Document(_PythBase):
    """
    Top-level item. One document is exactly one file.
    Documents consist of a list of paragraphs.
    """
    
    validProperties = ('title', 'subject', 'author')
    contentType = Paragraph