File: example_function.txt

package info (click to toggle)
rest2web 0.5.2~alpha%2Bsvn-r248-2.3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,256 kB
  • ctags: 870
  • sloc: python: 6,285; makefile: 64
file content (26 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (5)
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
#
# syntax coloring
try:
    import colorize as col
except ImportError:
    def colorize(filename):
        raise ImportError, 'Importing colorize.py failed.'

else:
    def colorize(filename):
        """
        format a python script as html
        Using the appropriate css it will be nicely colored.

        Needs the colorize.py module.
        """
        fullname = os.path.join(filename)
        f = open(fullname, 'r')
        data = f.read()
        f.close()

        p = col.Parser(data)
        p.format(None, None)
        src = p.getvalue()
        return src.replace('\n', '<br />\n').replace('  ', '&nbsp;&nbsp;')
        # to avoid having to use <pre>..