Attachment 'txt.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - plain text file Filter
   4 
   5     We try to support more than ASCII here.
   6 
   7     @copyright: 2006 by ThomasWaldmann MoinMoin:ThomasWaldmann
   8     @license: GNU GPL, see COPYING for details.
   9 """
  10 
  11 import codecs
  12 
  13 def execute(indexobj, filename):
  14     success = False
  15     for enc in ('utf-8', 'iso-8859-15', 'latin-1', ):
  16         try:
  17             f = codecs.open(filename, "r", enc)
  18             data = f.read()
  19             f.close()
  20             return data
  21         except UnicodeError, err:
  22             pass
  23     f = file(filename, "r")
  24     data = f.read()
  25     f.close()
  26     data = data.decode('ascii', 'replace')
  27     return data
  28     

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.