Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17967/idle
Modified Files:
Tag: py3k
AutoIndent.py CallTips.py FormatParagraph.py PyParse.py
Log Message:
Changes for Python 3
Index: FormatParagraph.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle/FormatParagraph.py,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** FormatParagraph.py 9 Aug 2008 16:47:07 -0000 1.2
--- FormatParagraph.py 29 Aug 2008 06:16:42 -0000 1.2.2.1
***************
*** 52,56 ****
# Reformat the comment lines - convert to text sans header.
lines = data.split("\n")
! lines = map(lambda st, l=len(comment_header): st[l:], lines)
data = "\n".join(lines)
# Reformat to 70 chars or a 20 char width, whichever is greater.
--- 52,56 ----
# Reformat the comment lines - convert to text sans header.
lines = data.split("\n")
! lines = list(map(lambda st, l=len(comment_header): st[l:], lines))
data = "\n".join(lines)
# Reformat to 70 chars or a 20 char width, whichever is greater.
Index: CallTips.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle/CallTips.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** CallTips.py 9 Aug 2008 16:47:07 -0000 1.3
--- CallTips.py 29 Aug 2008 06:16:42 -0000 1.3.2.1
***************
*** 101,105 ****
# constructor (ie, __init__() ) or None if we can't find one.
try:
! return class_ob.__init__.im_func
except AttributeError:
for base in class_ob.__bases__:
--- 101,105 ----
# constructor (ie, __init__() ) or None if we can't find one.
try:
! return class_ob.__init__.__func__
except AttributeError:
for base in class_ob.__bases__:
***************
*** 113,117 ****
if ob is not None:
argOffset = 0
! if type(ob)==types.ClassType:
# Look for the highest __init__ in the class chain.
fob = _find_constructor(ob)
--- 113,117 ----
if ob is not None:
argOffset = 0
! if type(ob)==type:
# Look for the highest __init__ in the class chain.
fob = _find_constructor(ob)
***************
*** 123,127 ****
# bit of a hack for methods - turn it into a function
# but we drop the "self" param.
! fob = ob.im_func
argOffset = 1
else:
--- 123,127 ----
# bit of a hack for methods - turn it into a function
# but we drop the "self" param.
! fob = ob.__func__
argOffset = 1
else:
***************
*** 130,141 ****
if type(fob) in [types.FunctionType, types.LambdaType]:
try:
! realArgs = fob.func_code.co_varnames[argOffset:fob.func_code.co_argcount]
! defaults = fob.func_defaults or []
! defaults = list(map(lambda name: "=%s" % name, defaults))
defaults = [""] * (len(realArgs)-len(defaults)) + defaults
! items = map(lambda arg, dflt: arg+dflt, realArgs, defaults)
! if fob.func_code.co_flags & 0x4:
items.append("...")
! if fob.func_code.co_flags & 0x8:
items.append("***")
argText = ", ".join(items)
--- 130,141 ----
if type(fob) in [types.FunctionType, types.LambdaType]:
try:
! realArgs = fob.__code__.co_varnames[argOffset:fob.__code__.co_argcount]
! defaults = fob.__defaults__ or []
! defaults = list(["=%s" % name for name in defaults])
defaults = [""] * (len(realArgs)-len(defaults)) + defaults
! items = list(map(lambda arg, dflt: arg+dflt, realArgs, defaults))
! if fob.__code__.co_flags & 0x4:
items.append("...")
! if fob.__code__.co_flags & 0x8:
items.append("***")
argText = ", ".join(items)
***************
*** 188,193 ****
if get_arg_text(t) != expected:
failed.append(t)
! print "%s - expected %s, but got %s" % (t, `expected`, `get_arg_text(t)`)
! print "%d of %d tests failed" % (len(failed), len(tests))
tc = TC()
--- 188,193 ----
if get_arg_text(t) != expected:
failed.append(t)
! print("%s - expected %s, but got %s" % (t, repr(expected), repr(get_arg_text(t))))
! print("%d of %d tests failed" % (len(failed), len(tests)))
tc = TC()
Index: AutoIndent.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle/AutoIndent.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** AutoIndent.py 9 Aug 2008 16:47:07 -0000 1.3
--- AutoIndent.py 29 Aug 2008 06:16:42 -0000 1.3.2.1
***************
*** 1,39 ****
! #from Tkinter import TclError
! #import tkMessageBox
! #import tkSimpleDialog
!
! ###$ event <<newline-and-indent>>
! ###$ win <Key-Return>
! ###$ win <KP_Enter>
! ###$ unix <Key-Return>
! ###$ unix <KP_Enter>
!
! ###$ event <<indent-region>>
! ###$ win <Control-bracketright>
! ###$ unix <Alt-bracketright>
! ###$ unix <Control-bracketright>
!
! ###$ event <<dedent-region>>
! ###$ win <Control-bracketleft>
! ###$ unix <Alt-bracketleft>
! ###$ unix <Control-bracketleft>
!
! ###$ event <<comment-region>>
! ###$ win <Alt-Key-3>
! ###$ unix <Alt-Key-3>
!
! ###$ event <<uncomment-region>>
! ###$ win <Alt-Key-4>
! ###$ unix <Alt-Key-4>
!
! ###$ event <<tabify-region>>
! ###$ win <Alt-Key-5>
! ###$ unix <Alt-Key-5>
!
! ###$ event <<untabify-region>>
! ###$ win <Alt-Key-6>
! ###$ unix <Alt-Key-6>
!
! import PyParse
class AutoIndent:
--- 1,4 ----
! import string
! from . import PyParse
class AutoIndent:
***************
*** 117,121 ****
def config(self, **options):
! for key, value in options.items():
if key == 'usetabs':
self.usetabs = value
--- 82,86 ----
def config(self, **options):
! for key, value in list(options.items()):
if key == 'usetabs':
self.usetabs = value
***************
*** 127,131 ****
self.context_use_ps1 = value
else:
! raise KeyError, "bad option name: %s" % `key`
# If ispythonsource and guess are true, guess a good value for
--- 92,96 ----
self.context_use_ps1 = value
else:
! raise KeyError("bad option name: %s" % repr(key))
# If ispythonsource and guess are true, guess a good value for
***************
*** 137,141 ****
def set_indentation_params(self, ispythonsource, guess=1):
if guess and ispythonsource:
! i = self.guess_indent()
if 2 <= i <= 8:
self.indentwidth = i
--- 102,106 ----
def set_indentation_params(self, ispythonsource, guess=1):
if guess and ispythonsource:
! i = 4 ## self.guess_indent()
if 2 <= i <= 8:
self.indentwidth = i
***************
*** 255,259 ****
for context in self.num_context_lines:
startat = max(lno - context, 1)
! startatindex = `startat` + ".0"
rawtext = text.get(startatindex, "insert")
y.set_str(rawtext)
--- 220,224 ----
for context in self.num_context_lines:
startat = max(lno - context, 1)
! startatindex = repr(startat) + ".0"
rawtext = text.get(startatindex, "insert")
y.set_str(rawtext)
***************
*** 287,291 ****
self.reindent_to(y.compute_backslash_indent())
else:
! assert 0, "bogus continuation type " + `c`
return "break"
--- 252,256 ----
self.reindent_to(y.compute_backslash_indent())
else:
! assert 0, "bogus continuation type " + repr(c)
return "break"
***************
*** 493,497 ****
elif ch == '\t':
raw = raw + 1
! effective = (effective / tabwidth + 1) * tabwidth
else:
break
--- 458,462 ----
elif ch == '\t':
raw = raw + 1
! effective = (effective // tabwidth + 1) * tabwidth
else:
break
***************
*** 519,545 ****
return ""
i = self.i = self.i + 1
! mark = `i` + ".0"
if self.text.compare(mark, ">=", "end"):
return ""
return self.text.get(mark, mark + " lineend+1c")
- def tokeneater(self, type, token, start, end, line,
- INDENT=_tokenize.INDENT,
- NAME=_tokenize.NAME,
- OPENERS=('class', 'def', 'for', 'if', 'try', 'while')):
- if self.finished:
- pass
- elif type == NAME and token in OPENERS:
- self.blkopenline = line
- elif type == INDENT and self.blkopenline:
- self.indentedline = line
- self.finished = 1
-
def run(self):
save_tabsize = _tokenize.tabsize
_tokenize.tabsize = self.tabwidth
try:
try:
! _tokenize.tokenize(self.readline, self.tokeneater)
except (_tokenize.TokenError, IndentationError):
# since we cut off the tokenizer early, we can trigger
--- 484,505 ----
return ""
i = self.i = self.i + 1
! mark = repr(i) + ".0"
if self.text.compare(mark, ">=", "end"):
return ""
return self.text.get(mark, mark + " lineend+1c")
def run(self):
+ OPENERS=('class', 'def', 'for', 'if', 'try', 'while')
save_tabsize = _tokenize.tabsize
_tokenize.tabsize = self.tabwidth
try:
try:
! for (typ, token, start, end, line) in _tokenize.tokenize(self.readline):
! if typ == NAME and token in OPENERS:
! self.blkopenline = line
! elif type == INDENT and self.blkopenline:
! self.indentedline = line
! break
!
except (_tokenize.TokenError, IndentationError):
# since we cut off the tokenizer early, we can trigger
Index: PyParse.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/idle/PyParse.py,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -d -r1.5 -r1.5.2.1
*** PyParse.py 9 Aug 2008 16:47:07 -0000 1.5
--- PyParse.py 29 Aug 2008 06:16:42 -0000 1.5.2.1
***************
*** 3,13 ****
import sys
- try:
- from types import UnicodeType
- except ImportError:
- from pywintypes import UnicodeType
-
# Reason last stmt is continued (or C_NONE if it's not).
! C_NONE, C_BACKSLASH, C_STRING, C_BRACKET = range(4)
if 0: # for throwaway debugging output
--- 3,8 ----
import sys
# Reason last stmt is continued (or C_NONE if it's not).
! C_NONE, C_BACKSLASH, C_STRING, C_BRACKET = list(range(4))
if 0: # for throwaway debugging output
***************
*** 119,135 ****
def set_str(self, str):
assert len(str) == 0 or str[-1] == '\n', "Oops - have str %r" % (str,)
! if type(str) == UnicodeType:
! # The parse functions have no idea what to do with Unicode, so
! # replace all Unicode characters with "x". This is "safe"
! # so long as the only characters germane to parsing the structure
! # of Python are 7-bit ASCII. It's *necessary* because Unicode
! # strings don't have a .translate() method that supports
! # deletechars.
! uniphooey = str
! str = []
! push = str.append
! for raw in map(ord, uniphooey):
! push(raw < 127 and chr(raw) or "x")
! str = "".join(str)
self.str = str
self.study_level = 0
--- 114,130 ----
def set_str(self, str):
assert len(str) == 0 or str[-1] == '\n', "Oops - have str %r" % (str,)
! ## if type(str) == UnicodeType:
! ## # The parse functions have no idea what to do with Unicode, so
! ## # replace all Unicode characters with "x". This is "safe"
! ## # so long as the only characters germane to parsing the structure
! ## # of Python are 7-bit ASCII. It's *necessary* because Unicode
! ## # strings don't have a .translate() method that supports
! ## # deletechars.
! ## uniphooey = str
! ## str = []
! ## push = str.append
! ## for raw in map(ord, uniphooey):
! ## push(raw < 127 and chr(raw) or "x")
! ## str = "".join(str)
self.str = str
self.study_level = 0
|