This file is indexed.

/usr/share/pyshared/slides.py is in python-slides 1.0.1-13build1.

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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Slides, a HTML slide generator
# Copyright (C) 2002 Moshe Zadka, Itamar Shtull-Trauring
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
# 
# This library 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
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""Slides, a HTML slide generator."""

__version__ = "1.0.1"


import os, string, cgi, types


class Lecture:
    """A series of slides.

    Arguments:
      name -- the name of the presentation, and then pass
      *slides -- Slide instances.
    
    When you're done call renderHTML().
    """
    
    css = None

    def __init__(self, name, *slides):
        self.name = name
	self.slides = slides
        
    def renderHTML(self, directory, basename, css=None):
        """Render all slides and their index.

        Arguments:
          directory -- directory in which to save slides.
          basename -- will be called with % index, so e.g. "slide-%d.html".
          [css] -- path to CSS file to use in output.
        """
        self.css = css
        self.renderSlide(self.slides[0], 1, directory, basename, prev=0)
        for i in range(1, len(self.slides)-1):
            self.renderSlide(self.slides[i], i+1, directory, basename)
        i = len(self.slides)-1
        self.renderSlide(self.slides[i], i+1, directory, basename, next=0)
        self.renderIndex(directory, basename)

    def getHeader(self):
        """Return the header for HTML pages."""
        result = '<html>\n<head>\n<title>%s</title>\n' % cgi.escape(self.name)
        if self.css:
            result += '<link rel="stylesheet" type="text/css" href="%s" />\n' % self.css
        return result + '</head>\n<body>\n'
    
    def getFooter(self):
        """Return the footer for HTML pages."""
        return '<br /><div class="footer"><hr />%s</div></body></html>' % self.name

    def getIndexFooter(self):
        """Return the footer for Index page."""
        return '<br /></body></html>'

    def renderIndex(self, directory, basename):
        """Render the index page of the presentation."""
        fp = open(os.path.join(directory, basename % 0), 'w')
        fp.write(self.getHeader())
        fp.write('<h2>%s</h2>\n' % self.name)
        fp.write('<ol>\n')
        for i in range(len(self.slides)):
            fp.write("<li><a href='%s'>%s</a></li>\n" %
                 (basename % (i+1), self.slides[i].title))
        fp.write('</ol>\n')
        fp.write(self.getIndexFooter())
        fp.close()

    def renderSlide(self, slide, i, directory, basename, prev=1, next=1):
        """Render a single slide."""
        html = slide.toHTML()
        if prev:
            prevName = basename % (i-1)
            prev = '<a accesskey="P" href="%s">Prev</a>' % prevName
        else:
            prev = 'Prev'
        if next:
            nextName = basename % (i+1)
            next = '<a acesskey="N" href="%s">Next</a>' % nextName
        else:
            next = 'Next'
        index = '<a href="%s">Index</a>' % (basename % 0)
        result = (self.getHeader() + " | ".join([prev, index, next]) +
              html + self.getFooter())
        fp = open(os.path.join(directory, basename % i), 'w')
        fp.write(result)
        fp.close()


class Slide:
    """A slide that contains unnumbered bullets.

    Arguments:
      title -- the slide's title.
      *bullets -- Bullet instances.
    """
    
    start = "<ul>\n"
    end = "</ul>\n"
    
    def __init__(self, title, *bullets):
        self.title = title
        self.bullets = bullets

    def toHTML(self):
        title = '<h2>%s</h2>' % cgi.escape(self.title)
        bullets = []
        for bullet in self.bullets:
            bullets.append(bullet.toHTML())
        return title + self.start + string.join(bullets, '\n') + self.end


class NumSlide(Slide):
    """A slide that contains numbered bullets.

    Arguments:
      title -- the slide's title.
      *bullets -- Bullet instances.
    """
    
    start = "<ol>\n"
    end = "</ol>\n"


class SubBullet:
    """A list of bullets that isn't a slide.

    Arguments:
      *bullets -- Bullet instances.
    """
    
    def __init__(self, *bullets):
        self.bullets = bullets

    def toHTML(self):
        bullets = []
        for bullet in self.bullets:
            bullets.append(toHTML(bullet))
        return '<ul>'+string.join(bullets, '\n')+'</ul>'


class Bullet:
    """A bullet."""
    
    def __init__(self, *texts):
        self.texts = texts

    def toHTML(self):        
        return '<li>'+ "".join(map(toHTML, self.texts)) + '</li>\n'


class PRE:
    """A quoted text."""
    
    def __init__(self, text):
        self.text = text

    def toHTML(self):
        return '<pre>\n'+cgi.escape(self.text)+'</pre>'


class URL:
    """A URL."""
    def __init__(self, text):
        self.text = text

    def toHTML(self):
        return '<a href="%s">%s</a>' % (self.text, self.text)


def toHTML(text):
    """Convert string or object to HTML."""
    if isinstance(text, types.StringType):
        return cgi.escape(text)
    else:
        return text.toHTML()


class Heading:
    """A heading of a given level (1, 2, ...)."""
    def __init__(self, num, text):
        self.num = num
        self.text = text

    def toHTML(self):
        return '<h%d>%s</h%d>' % (self.num, toHTML(self.text), self.num)


class Center:
    """Center an item."""
    
    def __init__(self, text):
        self.text = text

    def toHTML(self):
        return '<center>%s</center>' % toHTML(self.text)


class Image:
    """An image."""
    
    def __init__(self, image, description=""):
        self.image = image
        self.description = description
        
    def toHTML(self):
        return "<img src='%s' alt='%s' />" % (self.image, self.description)


class TitleSlide(Slide):

    def toHTML(self):
        title = '<h1>%s</h1>' % toHTML(Center(self.title))
        points = []
        for point in self.bullets:
            points.append(Center(point).toHTML())
        return title + '\n'.join(points)


__all__ = ["Lecture", "Slide", "NumSlide", "PRE", "URL", "Bullet",
           "SubBullet", "toHTML", "Center", "Heading", "Image", "TitleSlide"]