Use re in stead of regex, so we get rid of the annoying warning during startup.

This commit is contained in:
Jack Jansen 2001-02-21 13:54:31 +00:00
parent 2d0589be67
commit 9ad2752381
5 changed files with 54 additions and 47 deletions

View file

@ -603,9 +603,9 @@ def draw(self, visRgn = None):
self.drawselframe(1)
import regex
commentPat = regex.compile("[ \t]*\(#\)")
indentPat = regex.compile("\t*")
import re
commentPat = re.compile("[ \t]*\(#\)")
indentPat = re.compile("\t*")
class PyEditor(TextEditor):
@ -659,9 +659,9 @@ def domenu_uncomment(self):
snippet = self.getselectedtext()
lines = string.split(snippet, '\r')
for i in range(len(lines)):
res = commentPat.match(lines[i]) >= 0
if res > 0:
pos = commentPat.regs[1][0]
m = commentPat.match(lines[i])
if m:
pos = m.start(1)
lines[i] = lines[i][:pos] + lines[i][pos+1:]
snippet = string.join(lines, '\r')
self.insert(snippet)
@ -676,8 +676,9 @@ def domenu_comment(self):
indent = 3000 # arbitrary large number...
for line in lines:
if string.strip(line):
if indentPat.match(line):
indent = min(indent, indentPat.regs[0][1])
m = indentPat.match(line)
if m:
indent = min(indent, m.regs[0][1])
else:
indent = 0
break