Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3eec762

Browse files
committed
- fixed some re usage, partly so it'll still work when re uses pre instead
of sre, and partly fixing re -> regex porting oversights - fixed PyFontify.py so it actually *works* again..
1 parent 353ae58 commit 3eec762

4 files changed

Lines changed: 38 additions & 43 deletions

File tree

Mac/Tools/IDE/PyBrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
arrows = (nullid, closedid, openid, closedsolidid, opensolidid)
1515

16-
has_ctlcharsRE = re.compile('[\000-\037\177-\377]')
16+
has_ctlcharsRE = re.compile(r'[\000-\037\177-\377]')
1717
def ctlcharsREsearch(str):
1818
if has_ctlcharsRE.search(str) is None:
1919
return -1

Mac/Tools/IDE/PyEdit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def _escape(where, what) :
790790

791791
def _makewholewordpattern(word):
792792
# first, escape special regex chars
793-
for esc in "\\[]().*^+$?":
793+
for esc in "\\[]()|.*^+$?":
794794
word = _escape(word, esc)
795795
notwordcharspat = '[^' + _wordchars + ']'
796796
pattern = '(' + word + ')'
@@ -1166,7 +1166,7 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
11661166
PyDebugger.stop()
11671167

11681168

1169-
_identifieRE = re.compile("[A-Za-z_][A-Za-z_0-9]*")
1169+
_identifieRE = re.compile(r"[A-Za-z_][A-Za-z_0-9]*")
11701170

11711171
def identifieRE_match(str):
11721172
match = _identifieRE.match(str)

Mac/Tools/IDE/PyFontify.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
# Many thanks for regular expression debugging & authoring are due to:
2020
# Tim (the-incredib-ly y'rs) Peters and Cristian Tismer
2121
# So, who owns the copyright? ;-) How about this:
22-
# Copyright 1996-2000:
22+
# Copyright 1996-2001:
2323
# Mitchell S. Chapman,
2424
# Zachary Roadhouse,
2525
# Tim Peters,
2626
# Just van Rossum
2727

28-
__version__ = "0.3.3"
28+
__version__ = "0.4"
2929

30-
import string, re
30+
import string
31+
import re
3132

3233
# First a little helper, since I don't like to repeat things. (Tismer speaking)
3334
import string
@@ -43,50 +44,47 @@ def replace(where, what, with):
4344
"break", "else", "if", "or", "while",
4445
"class", "except", "import", "pass",
4546
"continue", "finally", "in", "print",
46-
"def", "for", "is", "raise"]
47+
"def", "for", "is", "raise", "yield"]
4748

4849
# Build up a regular expression which will match anything
4950
# interesting, including multi-line triple-quoted strings.
50-
commentPat = "#.*"
51+
commentPat = r"#[^\n]*"
5152

52-
pat = "q[^\q\n]*\(\\\\[\000-\377][^\q\n]*\)*q"
53-
quotePat = replace(pat, "q", "'") + "\|" + replace(pat, 'q', '"')
53+
pat = r"q[^\\q\n]*(\\[\000-\377][^\\q\n]*)*q"
54+
quotePat = replace(pat, "q", "'") + "|" + replace(pat, 'q', '"')
5455

5556
# Way to go, Tim!
56-
pat = """
57+
pat = r"""
5758
qqq
5859
[^\\q]*
59-
\(
60-
\( \\\\[\000-\377]
61-
\| q
62-
\( \\\\[\000-\377]
63-
\| [^\\q]
64-
\| q
65-
\( \\\\[\000-\377]
66-
\| [^\\q]
67-
\)
68-
\)
69-
\)
60+
(
61+
( \\[\000-\377]
62+
| q
63+
( \\[\000-\377]
64+
| [^\q]
65+
| q
66+
( \\[\000-\377]
67+
| [^\\q]
68+
)
69+
)
70+
)
7071
[^\\q]*
71-
\)*
72+
)*
7273
qqq
7374
"""
7475
pat = string.join(string.split(pat), '') # get rid of whitespace
75-
tripleQuotePat = replace(pat, "q", "'") + "\|" + replace(pat, 'q', '"')
76+
tripleQuotePat = replace(pat, "q", "'") + "|" + replace(pat, 'q', '"')
7677

7778
# Build up a regular expression which matches all and only
7879
# Python keywords. This will let us skip the uninteresting
7980
# identifier references.
8081
# nonKeyPat identifies characters which may legally precede
8182
# a keyword pattern.
82-
nonKeyPat = "\(^\|[^a-zA-Z0-9_.\"']\)"
83+
nonKeyPat = r"(^|[^a-zA-Z0-9_.\"'])"
8384

84-
keyPat = nonKeyPat + "\("
85-
for keyword in keywordsList:
86-
keyPat = keyPat + keyword + "\|"
87-
keyPat = keyPat[:-2] + "\)" + nonKeyPat
85+
keyPat = nonKeyPat + "(" + "|".join(keywordsList) + ")" + nonKeyPat
8886

89-
matchPat = commentPat + "\|" + keyPat + "\|" + tripleQuotePat + "\|" + quotePat
87+
matchPat = commentPat + "|" + keyPat + "|" + tripleQuotePat + "|" + quotePat
9088
matchRE = re.compile(matchPat)
9189

9290
idKeyPat = "[ \t]*[A-Za-z_][A-Za-z_0-9.]*" # Ident w. leading whitespace.
@@ -111,7 +109,10 @@ def fontify(pytext, searchfrom = 0, searchto = None):
111109
end = searchfrom
112110
while 1:
113111
m = search(pytext, end)
114-
if not m or m.start() >= searchto:
112+
if m is None:
113+
break # EXIT LOOP
114+
start = m.start()
115+
if start >= searchto:
115116
break # EXIT LOOP
116117
match = m.group(0)
117118
end = start + len(match)
@@ -132,10 +133,12 @@ def fontify(pytext, searchfrom = 0, searchto = None):
132133
# following identifier.
133134
if match in ["def", "class"]:
134135
m = idSearch(pytext, end)
135-
if m and m.start() == end:
136-
match = m.group(0)
137-
end = start + len(match)
138-
tags_append((identifierTag, start, end, None))
136+
if m is not None:
137+
start = m.start()
138+
if start == end:
139+
match = m.group(0)
140+
end = start + len(match)
141+
tags_append((identifierTag, start, end, None))
139142
elif c == "#":
140143
tags_append((commentTag, start, end, None))
141144
else:

Mac/Tools/IDE/Wcontrols.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,6 @@ def get(self):
381381
return self._value
382382

383383

384-
class __xxxx_PopupControl(ControlWidget):
385-
386-
def __init__(self, possize, title = "Button", callback = None):
387-
procID = Controls.popupMenuProc # | Controls.useWFont
388-
ControlWidget.__init__(self, possize, title, procID, callback, 0, 0, 1)
389-
self._isdefault = 0
390-
391-
392384
def _scalebarvalue(absmin, absmax, curmin, curmax):
393385
if curmin <= absmin and curmax >= absmax:
394386
return None

0 commit comments

Comments
 (0)