File: sourceforge.py

package info (click to toggle)
pyqwt3d 0.1.8-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 984 kB
  • sloc: python: 3,932; cpp: 328; makefile: 115; sh: 7
file content (35 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/env python

import os
import re
import sys

def stamp(html):
    """Stamp a Python HTML documentation page with the SourceForge logo"""

    def replace(m):
        return ('<span class="release-info">%s '
                'Hosted on <a href="http://sourceforge.net">'
                '<img src="http://sourceforge.net/'
                'sflogo.php?group_id=82987&type=1" width="88" height="31"'
                'border="0" alt="SourceForge Logo"></a></span>' % m.group(1))

    mailRe = re.compile(r'<span class="release-info">(.*)</span>')

    return re.sub(mailRe, replace, html)

# stamp()

if __name__ == '__main__':
    for name in sys.argv[1:]:
        html = open(name, 'r').read()
        text = stamp(html)
        if text != html:
            os.remove(name)
            file = open(name, 'w')
            file.write(text)
            file.close()

# Local Variables: ***
# mode: python ***
# End: ***