annotate MoinMoin/filter/text.py @ 6133:a6283e189869 tip

fixup: remove nonexisting passlib.utils._blowfish this was removed by the passlib 1.7.1 upgrade.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Jun 2017 18:10:19 +0200
parents bb2e053067fb
children
rev   line source
454
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - text/* file Filter
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 We try to support more than ASCII here.
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1805
diff changeset
7 @copyright: 2006 MoinMoin:ThomasWaldmann
454
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 """
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 import codecs
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
13 def execute(indexobj, filename):
790
930c9f03aa13 fix typo, remove superfluous encoding from text filter list
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 454
diff changeset
14 for enc in ('utf-8', 'iso-8859-15', ):
454
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15 try:
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
16 f = codecs.open(filename, "r", enc)
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17 data = f.read()
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 f.close()
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19 return data
1805
ebcebba1afb3 removed some unused attributes, used 'dummy' for dummies
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
20 except UnicodeError:
454
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
21 pass
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
22 f = file(filename, "r")
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
23 data = f.read()
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24 f.close()
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 data = data.decode('ascii', 'replace')
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 return data
e099072bba24 changed filters to use mimetypes
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27