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.
  • [get | view] (2006-02-13 12:15:36, 0.7 KB) [[attachment:binary.py]]
  • [get | view] (2006-02-13 12:15:37, 0.6 KB) [[attachment:sxw.py]]
  • [get | view] (2006-02-13 12:15:38, 0.7 KB) [[attachment:txt.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.