Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24802/Pythonwin/pywin/framework
Modified Files:
app.py dlgappcore.py help.py intpydde.py mdi_pychecker.py
scriptutils.py startup.py stdin.py winout.py
Log Message:
Various modernizations to .py code via the py3k branch.
Index: mdi_pychecker.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/mdi_pychecker.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mdi_pychecker.py 23 Oct 2008 07:39:12 -0000 1.3
--- mdi_pychecker.py 14 Nov 2008 00:22:25 -0000 1.4
***************
*** 57,61 ****
if os.path.isdir(d):
d = d.lower()
! if not dirs.has_key(d):
dirs[d] = None
if recurse:
--- 57,61 ----
if os.path.isdir(d):
d = d.lower()
! if d not in dirs:
dirs[d] = None
if recurse:
***************
*** 63,67 ****
for sd in subdirs:
sd = sd.lower()
! if not dirs.has_key(sd):
dirs[sd] = None
elif os.path.isfile(d):
--- 63,67 ----
for sd in subdirs:
sd = sd.lower()
! if sd not in dirs:
dirs[sd] = None
elif os.path.isfile(d):
***************
*** 69,73 ****
else:
x = None
! if os.environ.has_key(d):
x = dirpath(os.environ[d])
elif d[:5] == 'HKEY_':
--- 69,73 ----
else:
x = None
! if d in os.environ:
x = dirpath(os.environ[d])
elif d[:5] == 'HKEY_':
***************
*** 90,94 ****
if x:
for xd in x:
! if not dirs.has_key(xd):
dirs[xd] = None
if recurse:
--- 90,94 ----
if x:
for xd in x:
! if xd not in dirs:
dirs[xd] = None
if recurse:
***************
*** 96,100 ****
for sd in subdirs:
sd = sd.lower()
! if not dirs.has_key(sd):
dirs[sd] = None
self.dirs = []
--- 96,100 ----
for sd in subdirs:
sd = sd.lower()
! if sd not in dirs:
dirs[sd] = None
self.dirs = []
Index: startup.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/startup.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** startup.py 9 Aug 2008 18:37:22 -0000 1.4
--- startup.py 14 Nov 2008 00:22:25 -0000 1.5
***************
*** 57,61 ****
import app
if app.AppBuilder is None:
! raise TypeError, "No application object has been registered"
app.App = app.AppBuilder()
--- 57,61 ----
import app
if app.AppBuilder is None:
! raise TypeError("No application object has been registered")
app.App = app.AppBuilder()
Index: stdin.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/stdin.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** stdin.py 1 Oct 2008 14:44:52 -0000 1.4
--- stdin.py 14 Nov 2008 00:22:25 -0000 1.5
***************
*** 22,26 ****
true = 1
false = 0
! get_input_line = raw_input
class Stdin:
--- 22,29 ----
true = 1
false = 0
! try:
! get_input_line = raw_input # py2x
! except NameError:
! get_input_line = input # py3k
class Stdin:
***************
*** 120,124 ****
"""
if self.closed:
! return apply(self.real_file.readlines, sizehint)
result = []
--- 123,127 ----
"""
if self.closed:
! return self.real_file.readlines(*sizehint)
result = []
Index: app.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/app.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** app.py 11 Aug 2008 00:38:28 -0000 1.14
--- app.py 14 Nov 2008 00:22:25 -0000 1.15
***************
*** 11,17 ****
import string
import os
! from pywin.mfc import window, dialog, thread, afxres
import traceback
! from pywin.framework import scriptutils
## NOTE: App and AppBuild should NOT be used - instead, you should contruct your
--- 11,20 ----
import string
import os
! from pywin.mfc import window, dialog, afxres
! from pywin.mfc.thread import WinApp
import traceback
! import regutil
!
! import scriptutils
## NOTE: App and AppBuild should NOT be used - instead, you should contruct your
***************
*** 113,121 ****
return 0
! class CApp(thread.WinApp):
" A class for the application "
def __init__(self):
self.oldCallbackCaller = None
! thread.WinApp.__init__(self, win32ui.GetApp() )
self.idleHandlers = []
--- 116,124 ----
return 0
! class CApp(WinApp):
" A class for the application "
def __init__(self):
self.oldCallbackCaller = None
! WinApp.__init__(self, win32ui.GetApp() )
self.idleHandlers = []
***************
*** 169,173 ****
thisRet = handler(handler, count)
except:
! print "Idle handler %s failed" % (`handler`)
traceback.print_exc()
print "Idle handler removed from list"
--- 172,176 ----
thisRet = handler(handler, count)
except:
! print "Idle handler %s failed" % (repr(handler))
traceback.print_exc()
print "Idle handler removed from list"
***************
*** 196,200 ****
def OnHelp(self,id, code):
try:
- import regutil
if id==win32ui.ID_HELP_GUI_REF:
helpFile = regutil.GetRegisteredHelpFile("Pythonwin Reference")
--- 199,202 ----
***************
*** 365,382 ****
ret=dialog.GetSimpleInput(prompt)
if ret==None:
! raise KeyboardInterrupt, "operation cancelled"
return ret
def Win32Input(prompt=None):
"Provide input() for gui apps"
! return eval(raw_input(prompt))
! sys.modules['__builtin__'].raw_input=Win32RawInput
! sys.modules['__builtin__'].input=Win32Input
def HaveGoodGUI():
"""Returns true if we currently have a good gui available.
"""
! return sys.modules.has_key("pywin.framework.startup")
def CreateDefaultGUI( appClass = None):
--- 367,390 ----
ret=dialog.GetSimpleInput(prompt)
if ret==None:
! raise KeyboardInterrupt("operation cancelled")
return ret
def Win32Input(prompt=None):
"Provide input() for gui apps"
! return eval(input(prompt))
! try:
! raw_import
! # must be py2x...
! sys.modules['__builtin__'].raw_input=Win32RawInput
! except NameError:
! # must be py3k
! import code
! code.InteractiveConsole.input=Win32Input
def HaveGoodGUI():
"""Returns true if we currently have a good gui available.
"""
! return "pywin.framework.startup" in sys.modules
def CreateDefaultGUI( appClass = None):
Index: intpydde.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpydde.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** intpydde.py 22 Jun 2006 13:55:49 -0000 1.2
--- intpydde.py 14 Nov 2008 00:22:25 -0000 1.3
***************
*** 10,15 ****
from pywin.mfc import object
from dde import *
! import traceback
! import string
class DDESystemTopic(object.Object):
--- 10,14 ----
from pywin.mfc import object
from dde import *
! import sys, traceback
class DDESystemTopic(object.Object):
***************
*** 22,28 ****
self.app.OnDDECommand(data)
except:
# The DDE Execution failed.
print "Error executing DDE command."
! traceback.print_exc()
return 0
--- 21,28 ----
self.app.OnDDECommand(data)
except:
+ t,v,tb = sys.exc_info()
# The DDE Execution failed.
print "Error executing DDE command."
! traceback.print_exception(t,v,tb)
return 0
Index: dlgappcore.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/dlgappcore.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dlgappcore.py 21 Jun 2005 08:04:42 -0000 1.3
--- dlgappcore.py 14 Nov 2008 00:22:25 -0000 1.4
***************
*** 55,59 ****
if self.frame is None:
! raise error, "No dialog was created by CreateDialog()"
return
--- 55,59 ----
if self.frame is None:
! raise error("No dialog was created by CreateDialog()")
return
Index: help.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/help.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** help.py 2 Oct 2008 13:03:55 -0000 1.13
--- help.py 14 Nov 2008 00:22:25 -0000 1.14
***************
*** 143,147 ****
if helpIDMap:
! for id, (desc, fname) in helpIDMap.items():
otherMenu.AppendMenu(win32con.MF_ENABLED|win32con.MF_STRING,id, desc)
else:
--- 143,147 ----
if helpIDMap:
! for id, (desc, fname) in helpIDMap.iteritems():
otherMenu.AppendMenu(win32con.MF_ENABLED|win32con.MF_STRING,id, desc)
else:
Index: winout.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/winout.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** winout.py 9 Aug 2008 16:47:07 -0000 1.14
--- winout.py 14 Nov 2008 00:22:25 -0000 1.15
***************
*** 24,28 ****
from pywin.mfc import docview
from pywin.framework import app, window
- from pywintypes import UnicodeType
import win32ui, win32api, win32con
import Queue
--- 24,27 ----
***************
*** 109,113 ****
if type(appendParams)!=type(()):
appendParams = (appendParams,)
! apply(menu.AppendMenu, appendParams)
menu.TrackPopupMenu(params[5]) # track at mouse position.
return 0
--- 108,112 ----
if type(appendParams)!=type(()):
appendParams = (appendParams,)
! menu.AppendMenu(*appendParams)
menu.TrackPopupMenu(params[5]) # track at mouse position.
return 0
***************
*** 131,139 ****
return 1
except win32api.error, details:
! try:
! msg = details[2]
! except:
! msg = str(details)
! win32ui.SetStatusText("The help file could not be opened - %s" % msg)
return 1
except:
--- 130,134 ----
return 1
except win32api.error, details:
! win32ui.SetStatusText("The help file could not be opened - %s" % details.strerror)
return 1
except:
***************
*** 428,432 ****
return 0
! def QueueFlush(self, max = sys.maxint):
# Returns true if the queue is empty after the flush
# debug("Queueflush - %d, %d\n" % (max, self.outputQueue.qsize()))
--- 423,427 ----
return 0
! def QueueFlush(self, max = None):
# Returns true if the queue is empty after the flush
# debug("Queueflush - %d, %d\n" % (max, self.outputQueue.qsize()))
***************
*** 434,454 ****
items = []
rc = 0
! while max > 0:
try:
item = self.outputQueue.get_nowait()
- if is_platform_unicode:
- # Note is_platform_unicode is never true any more!
- if not isinstance(item, UnicodeType):
- item = unicode(item, default_platform_encoding)
- item = item.encode(default_scintilla_encoding) # What scintilla uses.
- else:
- # try and display using mbcs encoding
- if isinstance(item, UnicodeType):
- item = item.encode("mbcs")
items.append(item)
except Queue.Empty:
rc = 1
break
! max = max - 1
if len(items) != 0:
if not self.CheckRecreateWindow():
--- 429,441 ----
items = []
rc = 0
! while max is None or max > 0:
try:
item = self.outputQueue.get_nowait()
items.append(item)
except Queue.Empty:
rc = 1
break
! if max is not None:
! max = max - 1
if len(items) != 0:
if not self.CheckRecreateWindow():
***************
*** 498,502 ****
def RTFWindowOutput(*args, **kw):
kw['makeView'] = WindowOutputViewRTF
! return apply( WindowOutput, args, kw )
--- 485,489 ----
def RTFWindowOutput(*args, **kw):
kw['makeView'] = WindowOutputViewRTF
! return WindowOutput(*args, **kw)
***************
*** 509,516 ****
w = WindowOutput(queueing=flags.WQ_IDLE)
w.write("First bit of text\n")
! import thread
for i in range(5):
w.write("Hello from the main thread\n")
! thread.start_new(thread_test, (w,))
for i in range(2):
w.write("Hello from the main thread\n")
--- 496,503 ----
w = WindowOutput(queueing=flags.WQ_IDLE)
w.write("First bit of text\n")
! import _thread
for i in range(5):
w.write("Hello from the main thread\n")
! _thread.start_new(thread_test, (w,))
for i in range(2):
w.write("Hello from the main thread\n")
Index: scriptutils.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/scriptutils.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** scriptutils.py 23 Oct 2008 03:42:43 -0000 1.19
--- scriptutils.py 14 Nov 2008 00:22:25 -0000 1.20
***************
*** 97,101 ****
modBits.append(modBit)
# If on path, _and_ existing package of that name loaded.
! if IsOnPythonPath(path) and sys.modules.has_key(modBit) and \
( os.path.exists(os.path.join(path, '__init__.py')) or \
os.path.exists(os.path.join(path, '__init__.pyc')) or \
--- 97,101 ----
modBits.append(modBit)
# If on path, _and_ existing package of that name loaded.
! if IsOnPythonPath(path) and modBit in sys.modules and \
( os.path.exists(os.path.join(path, '__init__.py')) or \
os.path.exists(os.path.join(path, '__init__.pyc')) or \
***************
*** 159,165 ****
if bAutoSave and \
! (len(pathName)>0 or \
! doc.GetTitle()[:8]=="Untitled" or \
! doc.GetTitle()[:6]=="Script"): # if not a special purpose window
if doc.IsModified():
try:
--- 159,165 ----
if bAutoSave and \
! (len(pathName)>0 or \
! doc.GetTitle()[:8]=="Untitled" or \
! doc.GetTitle()[:6]=="Script"): # if not a special purpose window
if doc.IsModified():
try:
***************
*** 362,366 ****
if pathName is not None:
! if os.path.splitext(pathName)[1].lower() <> ".py":
pathName = None
--- 362,366 ----
if pathName is not None:
! if os.path.splitext(pathName)[1].lower() != ".py":
pathName = None
***************
*** 378,382 ****
modName, modExt = os.path.splitext(modName)
newPath = None
! for key, mod in sys.modules.items():
if hasattr(mod, '__file__'):
fname = mod.__file__
--- 378,382 ----
modName, modExt = os.path.splitext(modName)
newPath = None
! for key, mod in sys.modules.iteritems():
if hasattr(mod, '__file__'):
fname = mod.__file__
***************
*** 392,396 ****
if newPath: sys.path.append(newPath)
! if sys.modules.has_key(modName):
bNeedReload = 1
what = "reload"
--- 392,396 ----
if newPath: sys.path.append(newPath)
! if modName in sys.modules:
bNeedReload = 1
what = "reload"
***************
*** 404,408 ****
try:
! # always do an import, as it is cheap is already loaded. This ensures
# it is in our name space.
codeObj = compile('import '+modName,'<auto import>','exec')
--- 404,408 ----
try:
! # always do an import, as it is cheap if it's already loaded. This ensures
# it is in our name space.
codeObj = compile('import '+modName,'<auto import>','exec')
***************
*** 454,458 ****
def RunTabNanny(filename):
! import cStringIO
tabnanny = FindTabNanny()
if tabnanny is None:
--- 454,461 ----
def RunTabNanny(filename):
! try:
! import cStringIO as io
! except ImportError:
! import io
tabnanny = FindTabNanny()
if tabnanny is None:
***************
*** 461,465 ****
# Capture the tab-nanny output
! newout = cStringIO.StringIO()
old_out = sys.stderr, sys.stdout
sys.stderr = sys.stdout = newout
--- 464,468 ----
# Capture the tab-nanny output
! newout = io.StringIO()
old_out = sys.stderr, sys.stdout
sys.stderr = sys.stdout = newout
|