Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18639/Pythonwin/pywin/framework
Modified Files:
interact.py intpyapp.py sgrepmdi.py stdin.py
Log Message:
various syntax modernizations
Index: intpyapp.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpyapp.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** intpyapp.py 9 Aug 2008 16:47:07 -0000 1.11
--- intpyapp.py 26 Nov 2008 08:39:32 -0000 1.12
***************
*** 238,247 ****
argType = args[0]
if argStart >= len(args):
! raise TypeError, "The command line requires an additional arg."
if argType=="/edit":
# Load up the default application.
if dde:
fname = win32api.GetFullPathName(args[argStart])
! dde.Exec("win32ui.GetApp().OpenDocumentFile(%s)" % (`fname`))
else:
win32ui.GetApp().OpenDocumentFile(args[argStart])
--- 238,247 ----
argType = args[0]
if argStart >= len(args):
! raise TypeError("The command line requires an additional arg.")
if argType=="/edit":
# Load up the default application.
if dde:
fname = win32api.GetFullPathName(args[argStart])
! dde.Exec("win32ui.GetApp().OpenDocumentFile(%s)" % (repr(fname)))
else:
win32ui.GetApp().OpenDocumentFile(args[argStart])
***************
*** 259,263 ****
scriptutils.RunScript(args[argStart], ' '.join(args[argStart+1:]), 0)
elif argType=="/app":
! raise RuntimeError, "/app only supported for new instances of Pythonwin.exe"
elif argType=='/new': # Allow a new instance of Pythonwin
return 1
--- 259,263 ----
scriptutils.RunScript(args[argStart], ' '.join(args[argStart+1:]), 0)
elif argType=="/app":
! raise RuntimeError("/app only supported for new instances of Pythonwin.exe")
elif argType=='/new': # Allow a new instance of Pythonwin
return 1
***************
*** 268,277 ****
win32ui.MessageBox("The /dde command can only be used\r\nwhen Pythonwin is already running")
else:
! raise TypeError, "Command line arguments not recognised"
except:
typ, val, tb = sys.exc_info()
print "There was an error processing the command line args"
traceback.print_exception(typ, val, tb, None, sys.stdout)
! win32ui.OutputDebug("There was a problem with the command line args - %s: %s" % (`typ`,`val`))
tb = None # Prevent a cycle
--- 268,277 ----
win32ui.MessageBox("The /dde command can only be used\r\nwhen Pythonwin is already running")
else:
! raise TypeError("Command line arguments not recognised")
except:
typ, val, tb = sys.exc_info()
print "There was an error processing the command line args"
traceback.print_exception(typ, val, tb, None, sys.stdout)
! win32ui.OutputDebug("There was a problem with the command line args - %s: %s" % (repr(typ),repr(val)))
tb = None # Prevent a cycle
***************
*** 303,307 ****
#
def OnDDECommand(self, command):
- # print "DDE Executing", `command`
try:
exec command + "\n"
--- 303,306 ----
***************
*** 431,437 ****
# Only attempt to save editor documents.
from pywin.framework.editor import editorTemplate
! docs = filter(lambda doc: doc.IsModified() and doc.GetPathName(), editorTemplate.GetDocumentList())
! map(lambda doc: doc.OnSaveDocument(doc.GetPathName()), docs)
! win32ui.SetStatusText("%d documents saved" % len(docs), 1)
def OnViewToolbarDbg(self, id, code):
--- 430,439 ----
# Only attempt to save editor documents.
from pywin.framework.editor import editorTemplate
! num = 0
! for doc in editorTemplate.GetDocumentList():
! if doc.IsModified() and doc.GetPathName():
! num = num = 1
! doc.OnSaveDocument(doc.GetPathName())
! win32ui.SetStatusText("%d documents saved" % num, 1)
def OnViewToolbarDbg(self, id, code):
Index: interact.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/interact.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** interact.py 9 Aug 2008 16:47:07 -0000 1.17
--- interact.py 26 Nov 2008 08:39:32 -0000 1.18
***************
*** 331,335 ****
return
terms = (["\n" + sys.ps2] * (len(bufLines)-1)) + ['']
! for bufLine, term in map(None, bufLines, terms):
if bufLine.strip():
self.write( bufLine + term )
--- 331,335 ----
return
terms = (["\n" + sys.ps2] * (len(bufLines)-1)) + ['']
! for bufLine, term in zip(bufLines, terms):
if bufLine.strip():
self.write( bufLine + term )
Index: sgrepmdi.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/sgrepmdi.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** sgrepmdi.py 9 Aug 2008 16:47:07 -0000 1.7
--- sgrepmdi.py 26 Nov 2008 08:39:32 -0000 1.8
***************
*** 47,51 ****
if os.path.isdir(d):
d = d.lower()
! if not dirs.has_key(d):
dirs[d] = None
if recurse:
--- 47,51 ----
if os.path.isdir(d):
d = d.lower()
! if d not in dirs:
dirs[d] = None
if recurse:
***************
*** 53,57 ****
for sd in subdirs:
sd = sd.lower()
! if not dirs.has_key(sd):
dirs[sd] = None
elif os.path.isfile(d):
--- 53,57 ----
for sd in subdirs:
sd = sd.lower()
! if d not in dirs:
dirs[sd] = None
elif os.path.isfile(d):
***************
*** 59,63 ****
else:
x = None
! if os.environ.has_key(d):
x = dirpath(os.environ[d])
elif d[:5] == 'HKEY_':
--- 59,63 ----
else:
x = None
! if d in os.environ:
x = dirpath(os.environ[d])
elif d[:5] == 'HKEY_':
***************
*** 80,84 ****
if x:
for xd in x:
! if not dirs.has_key(xd):
dirs[xd] = None
if recurse:
--- 80,84 ----
if x:
for xd in x:
! if xd not in dirs:
dirs[xd] = None
if recurse:
***************
*** 86,90 ****
for sd in subdirs:
sd = sd.lower()
! if not dirs.has_key(sd):
dirs[sd] = None
self.dirs = []
--- 86,90 ----
for sd in subdirs:
sd = sd.lower()
! if sd not in dirs:
dirs[sd] = None
self.dirs = []
Index: stdin.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/stdin.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** stdin.py 26 Nov 2008 01:32:08 -0000 1.6
--- stdin.py 26 Nov 2008 08:39:33 -0000 1.7
***************
*** 34,38 ****
"""
if self.real_file is None:
! raise AttributeError, name
return getattr(self.real_file, name)
--- 34,38 ----
"""
if self.real_file is None:
! raise AttributeError(name)
return getattr(self.real_file, name)
|