Attachment 'binary.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - binary file Filter
4
5 Processes any binary file and extracts ASCII content from it.
6
7 @copyright: 2006 by ThomasWaldmann MoinMoin:ThomasWaldmann
8 @license: GNU GPL, see COPYING for details.
9 """
10
11 import string
12 norm = string.maketrans('', '') # builds a list of all characters
13 non_alnum = string.translate(norm, norm, string.letters+string.digits)
14 trans_nontext = string.maketrans(non_alnum, ' '*len(non_alnum))
15
16 def execute(indexobj, filename):
17 f = file(filename, "rb")
18 data = f.read()
19 f.close()
20 data = data.translate(trans_nontext)
21 data = ' '.join(data.split()) # remove lots of blanks
22 return data.decode('ascii')
23
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.