diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-02-21 13:54:31 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-02-21 13:54:31 (GMT) |
commit | 9ad2752381b10cae83eb9e8044aa77dfd87d7039 (patch) | |
tree | e06b55db8ff39a445a6dcc83622fc229348d0582 /Mac/Tools/IDE/PyFontify.py | |
parent | 2d0589be6739e15bc27ab8996ee0727a5a3dda51 (diff) | |
download | cpython-9ad2752381b10cae83eb9e8044aa77dfd87d7039.zip cpython-9ad2752381b10cae83eb9e8044aa77dfd87d7039.tar.gz cpython-9ad2752381b10cae83eb9e8044aa77dfd87d7039.tar.bz2 |
Use re in stead of regex, so we get rid of the annoying warning during startup.
Diffstat (limited to 'Mac/Tools/IDE/PyFontify.py')
-rw-r--r-- | Mac/Tools/IDE/PyFontify.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Mac/Tools/IDE/PyFontify.py b/Mac/Tools/IDE/PyFontify.py index 02de08e..b5d6102 100644 --- a/Mac/Tools/IDE/PyFontify.py +++ b/Mac/Tools/IDE/PyFontify.py @@ -27,7 +27,7 @@ sublist is not used, hence always None. __version__ = "0.3.3" -import string, regex +import string, re # First a little helper, since I don't like to repeat things. (Tismer speaking) import string @@ -87,10 +87,10 @@ for keyword in keywordsList: keyPat = keyPat[:-2] + "\)" + nonKeyPat matchPat = commentPat + "\|" + keyPat + "\|" + tripleQuotePat + "\|" + quotePat -matchRE = regex.compile(matchPat) +matchRE = re.compile(matchPat) idKeyPat = "[ \t]*[A-Za-z_][A-Za-z_0-9.]*" # Ident w. leading whitespace. -idRE = regex.compile(idKeyPat) +idRE = re.compile(idKeyPat) def fontify(pytext, searchfrom = 0, searchto = None): @@ -98,9 +98,7 @@ def fontify(pytext, searchfrom = 0, searchto = None): searchto = len(pytext) # Cache a few attributes for quicker reference. search = matchRE.search - group = matchRE.group idSearch = idRE.search - idGroup = idRE.group tags = [] tags_append = tags.append @@ -112,10 +110,10 @@ def fontify(pytext, searchfrom = 0, searchto = None): start = 0 end = searchfrom while 1: - start = search(pytext, end) - if start < 0 or start >= searchto: + m = search(pytext, end) + if not m or m.start() >= searchto: break # EXIT LOOP - match = group(0) + match = m.group(0) end = start + len(match) c = match[0] if c not in "#'\"": @@ -133,9 +131,9 @@ def fontify(pytext, searchfrom = 0, searchto = None): # If this was a defining keyword, look ahead to the # following identifier. if match in ["def", "class"]: - start = idSearch(pytext, end) - if start == end: - match = idGroup(0) + m = idSearch(pytext, end) + if m and m.start() == end: + match = m.group(0) end = start + len(match) tags_append((identifierTag, start, end, None)) elif c == "#": |