comparison MoinMoin/formatter/__init__.py @ 1181:a7f8dceb4410

remove types module usage
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Aug 2006 00:12:34 +0200
parents 97ce857bdebf
children bc84eae93f8c
comparison
equal deleted inserted replaced
1180:c1c0d7f6f2b4 1181:a7f8dceb4410
5 See "base.py" for the formatter interface. 5 See "base.py" for the formatter interface.
6 6
7 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de> 7 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>
8 @license: GNU GPL, see COPYING for details. 8 @license: GNU GPL, see COPYING for details.
9 """ 9 """
10 import re
11
10 from MoinMoin.util import pysupport 12 from MoinMoin.util import pysupport
13 from MoinMoin import wikiutil
11 14
12 modules = pysupport.getPackageModules(__file__) 15 modules = pysupport.getPackageModules(__file__)
13 16
14 from MoinMoin import wikiutil
15 import re, types
16 17
17 class FormatterBase: 18 class FormatterBase:
18 """ This defines the output interface used all over the rest of the code. 19 """ This defines the output interface used all over the rest of the code.
19 20
20 Note that no other means should be used to generate _content_ output, 21 Note that no other means should be used to generate _content_ output,
35 self.in_pre = 0 36 self.in_pre = 0
36 self._highlight_re = None 37 self._highlight_re = None
37 self._base_depth = 0 38 self._base_depth = 0
38 39
39 def set_highlight_re(self, hi_re=None): 40 def set_highlight_re(self, hi_re=None):
40 if type(hi_re) in [types.StringType, types.UnicodeType]: 41 if isinstance(hi_re, (str, unicode)):
41 try: 42 try:
42 self._highlight_re = re.compile(hi_re, re.U + re.IGNORECASE) 43 self._highlight_re = re.compile(hi_re, re.U + re.IGNORECASE)
43 except re.error: 44 except re.error:
44 hi_re = re.escape(hi_re) 45 hi_re = re.escape(hi_re)
45 self._highlight_re = re.compile(hi_re, re.U + re.IGNORECASE) 46 self._highlight_re = re.compile(hi_re, re.U + re.IGNORECASE)