[Python-checkins] CVS: python/dist/src/Mac/Tools/IDE PyBrowser.py,1.8,1.9 PyEdit.py,1.20,1.21 PyFontify.py,1.4,1.5 Wcontrols.py,1.5,1.6

Just van Rossum jvr@users.sourceforge.net
Tue, 10 Jul 2001 12:25:42 -0700


Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE
In directory usw-pr-cvs1:/tmp/cvs-serv30899

Modified Files:
	PyBrowser.py PyEdit.py PyFontify.py Wcontrols.py 
Log Message:
- 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..

Index: PyBrowser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyBrowser.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** PyBrowser.py	2001/06/19 21:37:32	1.8
--- PyBrowser.py	2001/07/10 19:25:40	1.9
***************
*** 14,18 ****
  arrows = (nullid, closedid, openid, closedsolidid, opensolidid)
  
! has_ctlcharsRE = re.compile('[\000-\037\177-\377]')
  def ctlcharsREsearch(str):
  	if has_ctlcharsRE.search(str) is None:
--- 14,18 ----
  arrows = (nullid, closedid, openid, closedsolidid, opensolidid)
  
! has_ctlcharsRE = re.compile(r'[\000-\037\177-\377]')
  def ctlcharsREsearch(str):
  	if has_ctlcharsRE.search(str) is None:

Index: PyEdit.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyEdit.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** PyEdit.py	2001/07/05 07:06:26	1.20
--- PyEdit.py	2001/07/10 19:25:40	1.21
***************
*** 791,795 ****
  def _makewholewordpattern(word):
  	# first, escape special regex chars
! 	for esc in "\\[]().*^+$?":
  		word = _escape(word, esc)
  	notwordcharspat = '[^' + _wordchars + ']'
--- 791,795 ----
  def _makewholewordpattern(word):
  	# first, escape special regex chars
! 	for esc in "\\[]()|.*^+$?":
  		word = _escape(word, esc)
  	notwordcharspat = '[^' + _wordchars + ']'
***************
*** 1167,1171 ****
  
  
! _identifieRE = re.compile("[A-Za-z_][A-Za-z_0-9]*")
  
  def identifieRE_match(str):
--- 1167,1171 ----
  
  
! _identifieRE = re.compile(r"[A-Za-z_][A-Za-z_0-9]*")
  
  def identifieRE_match(str):

Index: PyFontify.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PyFontify.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** PyFontify.py	2001/02/21 13:54:31	1.4
--- PyFontify.py	2001/07/10 19:25:40	1.5
***************
*** 20,24 ****
  #	Tim (the-incredib-ly y'rs) Peters and Cristian Tismer
  # So, who owns the copyright? ;-) How about this:
! # Copyright 1996-2000: 
  #	Mitchell S. Chapman,
  #	Zachary Roadhouse,
--- 20,24 ----
  #	Tim (the-incredib-ly y'rs) Peters and Cristian Tismer
  # So, who owns the copyright? ;-) How about this:
! # Copyright 1996-2001: 
  #	Mitchell S. Chapman,
  #	Zachary Roadhouse,
***************
*** 26,32 ****
  #	Just van Rossum
  
! __version__ = "0.3.3"
  
! import string, re
  
  # First a little helper, since I don't like to repeat things. (Tismer speaking)
--- 26,33 ----
  #	Just van Rossum
  
! __version__ = "0.4"
  
! import string
! import re
  
  # First a little helper, since I don't like to repeat things. (Tismer speaking)
***************
*** 44,77 ****
  	"class", "except", "import", "pass",
  	"continue", "finally", "in", "print",
! 	"def", "for", "is", "raise"]
  
  # Build up a regular expression which will match anything
  # interesting, including multi-line triple-quoted strings.
! commentPat = "#.*"
  
! pat = "q[^\q\n]*\(\\\\[\000-\377][^\q\n]*\)*q"
! quotePat = replace(pat, "q", "'") + "\|" + replace(pat, 'q', '"')
  
  # Way to go, Tim!
! pat = """
  	qqq
  	[^\\q]*
! 	\(
! 		\(	\\\\[\000-\377]
! 		\|	q
! 			\(	\\\\[\000-\377]
! 			\|	[^\\q]
! 			\|	q
! 				\(	\\\\[\000-\377]
! 				\|	[^\\q]
! 				\)
! 			\)
! 		\)
  		[^\\q]*
! 	\)*
  	qqq
  """
  pat = string.join(string.split(pat), '')	# get rid of whitespace
! tripleQuotePat = replace(pat, "q", "'") + "\|" + replace(pat, 'q', '"')
  
  # Build up a regular expression which matches all and only
--- 45,78 ----
  	"class", "except", "import", "pass",
  	"continue", "finally", "in", "print",
! 	"def", "for", "is", "raise", "yield"]
  
  # Build up a regular expression which will match anything
  # interesting, including multi-line triple-quoted strings.
! commentPat = r"#[^\n]*"
  
! pat = r"q[^\\q\n]*(\\[\000-\377][^\\q\n]*)*q"
! quotePat = replace(pat, "q", "'") + "|" + replace(pat, 'q', '"')
  
  # Way to go, Tim!
! pat = r"""
  	qqq
  	[^\\q]*
! 	(
! 		(	\\[\000-\377]
! 		|	q
! 			(	\\[\000-\377]
! 			|	[^\q]
! 			|	q
! 				(	\\[\000-\377]
! 				|	[^\\q]
! 				)
! 			)
! 		)
  		[^\\q]*
! 	)*
  	qqq
  """
  pat = string.join(string.split(pat), '')	# get rid of whitespace
! tripleQuotePat = replace(pat, "q", "'") + "|" + replace(pat, 'q', '"')
  
  # Build up a regular expression which matches all and only
***************
*** 80,91 ****
  # nonKeyPat identifies characters which may legally precede
  # a keyword pattern.
! nonKeyPat = "\(^\|[^a-zA-Z0-9_.\"']\)"
  
! keyPat = nonKeyPat + "\("
! for keyword in keywordsList:
! 	keyPat = keyPat + keyword + "\|"
! keyPat = keyPat[:-2] + "\)" + nonKeyPat
  
! matchPat = commentPat + "\|" + keyPat + "\|" + tripleQuotePat + "\|" + quotePat
  matchRE = re.compile(matchPat)
  
--- 81,89 ----
  # nonKeyPat identifies characters which may legally precede
  # a keyword pattern.
! nonKeyPat = r"(^|[^a-zA-Z0-9_.\"'])"
  
! keyPat = nonKeyPat + "(" + "|".join(keywordsList) + ")" + nonKeyPat
  
! matchPat = commentPat + "|" + keyPat + "|" + tripleQuotePat + "|" + quotePat
  matchRE = re.compile(matchPat)
  
***************
*** 112,116 ****
  	while 1:
  		m = search(pytext, end)
! 		if not m or m.start() >= searchto:
  			break	# EXIT LOOP
  		match = m.group(0)
--- 110,117 ----
  	while 1:
  		m = search(pytext, end)
! 		if m is None:
! 			break	# EXIT LOOP
! 		start = m.start()
! 		if start >= searchto:
  			break	# EXIT LOOP
  		match = m.group(0)
***************
*** 133,140 ****
  			if match in ["def", "class"]:
  				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 == "#":
  			tags_append((commentTag, start, end, None))
--- 134,143 ----
  			if match in ["def", "class"]:
  				m = idSearch(pytext, end)
! 				if m is not None:
! 					start = m.start()
! 					if start == end:
! 						match = m.group(0)
! 						end = start + len(match)
! 						tags_append((identifierTag, start, end, None))
  		elif c == "#":
  			tags_append((commentTag, start, end, None))

Index: Wcontrols.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/Wcontrols.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Wcontrols.py	2001/01/23 14:58:20	1.5
--- Wcontrols.py	2001/07/10 19:25:40	1.6
***************
*** 382,393 ****
  	
  
- class __xxxx_PopupControl(ControlWidget):
- 	
- 	def __init__(self, possize, title = "Button", callback = None):
- 		procID = Controls.popupMenuProc	# | Controls.useWFont
- 		ControlWidget.__init__(self, possize, title, procID, callback, 0, 0, 1)
- 		self._isdefault = 0
- 	
- 
  def _scalebarvalue(absmin, absmax, curmin, curmax):
  	if curmin <= absmin and curmax >= absmax:
--- 382,385 ----