Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20885/client
Modified Files:
Tag: py3k
CLSIDToClass.py __init__.py build.py combrowse.py dynamic.py
gencache.py genpy.py makepy.py selecttlb.py tlbrowse.py
util.py
Log Message:
Changes to build for Py3k
Index: makepy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -C2 -d -r1.25 -r1.25.2.1
*** makepy.py 1 Jul 2008 00:17:41 -0000 1.25
--- makepy.py 29 Aug 2008 08:58:53 -0000 1.25.2.1
***************
*** 67,74 ****
"""
! import genpy, string, sys, os, types, pythoncom
! import codecs
! import selecttlb
! import gencache
from win32com.client import NeedUnicodeConversions, Dispatch
--- 67,74 ----
"""
! import sys, os, types, pythoncom
! from win32com.client import genpy
! from . import selecttlb
! from . import gencache
from win32com.client import NeedUnicodeConversions, Dispatch
***************
*** 102,110 ****
else:
desc = tlb.GetDocumentation(-1)[0]
! print desc
! print " %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)
! print " >>> # Use these commands in Python code to auto generate .py support"
! print " >>> from win32com.client import gencache"
! print " >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)
class SimpleProgress(genpy.GeneratorProgress):
--- 102,110 ----
else:
desc = tlb.GetDocumentation(-1)[0]
! print(desc)
! print(" %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor))
! print(" >>> # Use these commands in Python code to auto generate .py support")
! print(" >>> from win32com.client import gencache")
! print(" >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor))
class SimpleProgress(genpy.GeneratorProgress):
***************
*** 190,194 ****
pass
if len(tlbs)==0:
! print "Could not locate a type library matching '%s'" % (arg)
for spec in tlbs:
# Version numbers not always reliable if enumerated from registry.
--- 190,194 ----
pass
if len(tlbs)==0:
! print("Could not locate a type library matching '%s'" % (arg))
for spec in tlbs:
# Version numbers not always reliable if enumerated from registry.
***************
*** 218,222 ****
if bForDemand and file is not None:
! raise RuntimeError, "You can only perform a demand-build when the output goes to the gen_py directory"
if type(typelibInfo)==type(()):
# Tuple
--- 218,222 ----
if bForDemand and file is not None:
! raise RuntimeError("You can only perform a demand-build when the output goes to the gen_py directory")
if type(typelibInfo)==type(()):
# Tuple
***************
*** 267,279 ****
else:
outputName = full_name + ".py"
! # generate to a temp file (so errors don't leave a 1/2
! # generated file) and one which can handle unicode!
! try:
! os.unlink(outputName)
! except os.error:
! pass
! encoding = 'mbcs' # could make this a param.
! fileUse = codecs.open(outputName + ".temp", "wt",
! encoding)
progress.LogBeginGenerate(outputName)
else:
--- 267,271 ----
else:
outputName = full_name + ".py"
! fileUse = open(outputName, "wt")
progress.LogBeginGenerate(outputName)
else:
***************
*** 286,290 ****
if file is None:
fileUse.close()
- os.rename(outputName + ".temp", outputName)
if bToGenDir:
--- 278,281 ----
***************
*** 357,361 ****
bForDemand = not bForDemand
! except (getopt.error, error), msg:
sys.stderr.write (str(msg) + "\n")
usage()
--- 348,352 ----
bForDemand = not bForDemand
! except (getopt.error, error) as msg:
sys.stderr.write (str(msg) + "\n")
usage()
Index: dynamic.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -C2 -d -r1.22 -r1.22.2.1
*** dynamic.py 26 Aug 2007 03:42:13 -0000 1.22
--- dynamic.py 29 Aug 2008 08:58:53 -0000 1.22.2.1
***************
*** 17,29 ****
"""
import traceback
- import string
- import new
-
import pythoncom
import winerror
! import build
! from types import StringType, IntType, TupleType, ListType
! from pywintypes import UnicodeType, IIDType
import win32com.client # Needed as code we eval() references it.
--- 17,27 ----
"""
import traceback
import pythoncom
import winerror
! from . import build
!
! import types
! from pywintypes import IIDType
import win32com.client # Needed as code we eval() references it.
***************
*** 56,76 ****
if debugging:
for arg in args:
! print arg,
! print
def debug_attr_print(*args):
if debugging_attr:
for arg in args:
! print arg,
! print
# get the type objects for IDispatch and IUnknown
dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown]
- _GoodDispatchType=[StringType,IIDType,UnicodeType]
_defaultDispatchItem=build.DispatchItem
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
! if type(IDispatch) in _GoodDispatchType:
try:
IDispatch = pythoncom.connect(IDispatch)
--- 54,73 ----
if debugging:
for arg in args:
! print(arg, end=' ')
! print()
def debug_attr_print(*args):
if debugging_attr:
for arg in args:
! print(arg, end=' ')
! print()
# get the type objects for IDispatch and IUnknown
dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown]
_defaultDispatchItem=build.DispatchItem
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
! if isinstance(IDispatch, (str, IIDType)):
try:
IDispatch = pythoncom.connect(IDispatch)
***************
*** 86,98 ****
# displayed to the user in repr() etc.
if userName is None:
! if type(IDispatch) == StringType:
userName = IDispatch
! elif type(IDispatch) == UnicodeType:
! # We always want the displayed name to be a real string
! userName = IDispatch.encode("ascii", "replace")
! elif type(userName) == UnicodeType:
! # As above - always a string...
! userName = userName.encode("ascii", "replace")
! else:
userName = str(userName)
return (_GetGoodDispatch(IDispatch, clsctx), userName)
--- 83,93 ----
# displayed to the user in repr() etc.
if userName is None:
! if isinstance(IDispatch, str):
userName = IDispatch
! ## elif type(IDispatch) == UnicodeType:
! ## # We always want the displayed name to be a real string
! ## userName = IDispatch.encode("ascii", "replace")
! elif not isinstance(userName, str):
!
userName = str(userName)
return (_GetGoodDispatch(IDispatch, clsctx), userName)
***************
*** 171,177 ****
allArgs = (dispid,LCID,invkind,1) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError, "This dispatch object does not define a default method"
! def __nonzero__(self):
return 1 # ie "if object:" should always be "true" - without this, __len__ is tried.
# _Possibly_ want to defer to __len__ if available, but Im not sure this is
--- 166,172 ----
allArgs = (dispid,LCID,invkind,1) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError("This dispatch object does not define a default method")
! def __bool__(self):
return 1 # ie "if object:" should always be "true" - without this, __len__ is tried.
# _Possibly_ want to defer to __len__ if available, but Im not sure this is
***************
*** 186,191 ****
try:
return str(self.__call__())
! except pythoncom.com_error, details:
! if details[0] not in ERRORS_BAD_CONTEXT:
raise
return self.__repr__()
--- 181,186 ----
try:
return str(self.__call__())
! except pythoncom.com_error as details:
! if details.args[0] not in ERRORS_BAD_CONTEXT:
raise
return self.__repr__()
***************
*** 203,207 ****
if invkind:
return self._oleobj_.Invoke(dispid, LCID, invkind, 1)
! raise TypeError, "This dispatch object does not define a Count method"
def _NewEnum(self):
--- 198,202 ----
if invkind:
return self._oleobj_.Invoke(dispid, LCID, invkind, 1)
! raise TypeError("This dispatch object does not define a Count method")
def _NewEnum(self):
***************
*** 211,215 ****
except pythoncom.com_error:
return None # no enumerator for this object.
! import util
return util.WrapEnum(enum, None)
--- 206,210 ----
except pythoncom.com_error:
return None # no enumerator for this object.
! from . import util
return util.WrapEnum(enum, None)
***************
*** 217,221 ****
# Improved __getitem__ courtesy Syver Enstad
# Must check _NewEnum before Item, to ensure b/w compat.
! if isinstance(index, IntType):
if self.__dict__['_enum_'] is None:
self.__dict__['_enum_'] = self._NewEnum()
--- 212,216 ----
# Improved __getitem__ courtesy Syver Enstad
# Must check _NewEnum before Item, to ensure b/w compat.
! if isinstance(index, int):
if self.__dict__['_enum_'] is None:
self.__dict__['_enum_'] = self._NewEnum()
***************
*** 226,230 ****
if invkind is not None:
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
! raise TypeError, "This object does not support enumeration"
def __setitem__(self, index, *args):
--- 221,225 ----
if invkind is not None:
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
! raise TypeError("This object does not support enumeration")
def __setitem__(self, index, *args):
***************
*** 238,249 ****
allArgs = (dispid,LCID,invkind,0,index) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError, "This dispatch object does not define a default method"
def _find_dispatch_type_(self, methodName):
! if self._olerepr_.mapFuncs.has_key(methodName):
item = self._olerepr_.mapFuncs[methodName]
return item.desc[4], item.dispid
! if self._olerepr_.propMapGet.has_key(methodName):
item = self._olerepr_.propMapGet[methodName]
return item.desc[4], item.dispid
--- 233,244 ----
allArgs = (dispid,LCID,invkind,0,index) + args
return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
! raise TypeError("This dispatch object does not define a default method")
def _find_dispatch_type_(self, methodName):
! if methodName in self._olerepr_.mapFuncs:
item = self._olerepr_.mapFuncs[methodName]
return item.desc[4], item.dispid
! if methodName in self._olerepr_.propMapGet:
item = self._olerepr_.propMapGet[methodName]
return item.desc[4], item.dispid
***************
*** 274,281 ****
# make a new instance of (probably this) class.
return self._wrap_dispatch_(ob, userName, ReturnCLSID)
! elif self._unicode_to_string_ and UnicodeType==type(ob):
! return str(ob)
! else:
! return ob
def _get_good_object_(self,ob,userName = None, ReturnCLSID=None):
--- 269,273 ----
# make a new instance of (probably this) class.
return self._wrap_dispatch_(ob, userName, ReturnCLSID)
! return ob
def _get_good_object_(self,ob,userName = None, ReturnCLSID=None):
***************
*** 285,289 ****
if ob is None: # Quick exit!
return None
! elif type(ob)==TupleType:
return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob))
else:
--- 277,281 ----
if ob is None: # Quick exit!
return None
! elif isinstance(ob, tuple):
return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob))
else:
***************
*** 294,298 ****
methodName = build.MakePublicAttributeName(name) # translate keywords etc.
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
! methodCode = string.join(methodCodeList,"\n")
try:
# print "Method code for %s is:\n" % self._username_, methodCode
--- 286,290 ----
methodName = build.MakePublicAttributeName(name) # translate keywords etc.
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
! methodCode = "\n".join(methodCodeList)
try:
# print "Method code for %s is:\n" % self._username_, methodCode
***************
*** 304,312 ****
globNameSpace = globals().copy()
globNameSpace["Dispatch"] = win32com.client.Dispatch
! exec codeObject in globNameSpace, tempNameSpace # self.__dict__, self.__dict__
name = methodName
# Save the function in map.
fn = self._builtMethods_[name] = tempNameSpace[name]
! newMeth = new.instancemethod(fn, self, self.__class__)
return newMeth
except:
--- 296,304 ----
globNameSpace = globals().copy()
globNameSpace["Dispatch"] = win32com.client.Dispatch
! exec(codeObject, globNameSpace, tempNameSpace) # self.__dict__, self.__dict__
name = methodName
# Save the function in map.
fn = self._builtMethods_[name] = tempNameSpace[name]
! newMeth = types.MethodType(fn, self)
return newMeth
except:
***************
*** 318,322 ****
"""Cleanup object - like a close - to force cleanup when you dont
want to rely on Python's reference counting."""
! for childCont in self._mapCachedItems_.values():
childCont._Release_()
self._mapCachedItems_ = {}
--- 310,314 ----
"""Cleanup object - like a close - to force cleanup when you dont
want to rely on Python's reference counting."""
! for childCont in list(self._mapCachedItems_.values()):
childCont._Release_()
self._mapCachedItems_ = {}
***************
*** 336,357 ****
return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) ))
except KeyError:
! raise AttributeError, name
def _print_details_(self):
"Debug routine - dumps what it knows about an object."
! print "AxDispatch container",self._username_
try:
! print "Methods:"
! for method in self._olerepr_.mapFuncs.keys():
! print "\t", method
! print "Props:"
! for prop, entry in self._olerepr_.propMap.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
! print "Get Props:"
! for prop, entry in self._olerepr_.propMapGet.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
! print "Put Props:"
! for prop, entry in self._olerepr_.propMapPut.items():
! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`)
except:
traceback.print_exc()
--- 328,349 ----
return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) ))
except KeyError:
! raise AttributeError(name)
def _print_details_(self):
"Debug routine - dumps what it knows about an object."
! print("AxDispatch container",self._username_)
try:
! print("Methods:")
! for method in list(self._olerepr_.mapFuncs.keys()):
! print("\t", method)
! print("Props:")
! for prop, entry in list(self._olerepr_.propMap.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
! print("Get Props:")
! for prop, entry in list(self._olerepr_.propMapGet.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
! print("Put Props:")
! for prop, entry in list(self._olerepr_.propMapPut.items()):
! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry)))
except:
traceback.print_exc()
***************
*** 428,432 ****
enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),())
except pythoncom.com_error:
! raise AttributeError, "This object can not function as an iterator"
# We must return a callable object.
class Factory:
--- 420,424 ----
enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),())
except pythoncom.com_error:
! raise AttributeError("This object can not function as an iterator")
# We must return a callable object.
class Factory:
***************
*** 439,446 ****
if attr[0]=='_' and attr[-1]=='_': # Fast-track.
! raise AttributeError, attr
# If a known method, create new instance and return.
try:
! return new.instancemethod(self._builtMethods_[attr], self, self.__class__)
except KeyError:
pass
--- 431,438 ----
if attr[0]=='_' and attr[-1]=='_': # Fast-track.
! raise AttributeError(attr)
# If a known method, create new instance and return.
try:
! return types.MethodType(self._builtMethods_[attr], self)
except KeyError:
pass
***************
*** 451,455 ****
# means we create the actual method object - which also means
# this code will never be asked for that method name again.
! if self._olerepr_.mapFuncs.has_key(attr):
return self._make_method_(attr)
--- 443,447 ----
# means we create the actual method object - which also means
# this code will never be asked for that method name again.
! if attr in self._olerepr_.mapFuncs:
return self._make_method_(attr)
***************
*** 465,469 ****
try:
if self.__LazyMap__(attr):
! if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr)
retEntry = self._olerepr_.propMap.get(attr)
if retEntry is None:
--- 457,461 ----
try:
if self.__LazyMap__(attr):
! if attr in self._olerepr_.mapFuncs: return self._make_method_(attr)
retEntry = self._olerepr_.propMap.get(attr)
if retEntry is None:
***************
*** 488,505 ****
try:
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
! except pythoncom.com_error, details:
if details[0] in ERRORS_BAD_CONTEXT:
# May be a method.
self._olerepr_.mapFuncs[attr] = retEntry
return self._make_method_(attr)
! raise pythoncom.com_error, details
debug_attr_print("OLE returned ", ret)
return self._get_good_object_(ret)
# no where else to look.
! raise AttributeError, "%s.%s" % (self._username_, attr)
def __setattr__(self, attr, value):
! if self.__dict__.has_key(attr): # Fast-track - if already in our dict, just make the assignment.
# XXX - should maybe check method map - if someone assigns to a method,
# it could mean something special (not sure what, tho!)
--- 480,497 ----
try:
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
! except pythoncom.com_error as details:
if details[0] in ERRORS_BAD_CONTEXT:
# May be a method.
self._olerepr_.mapFuncs[attr] = retEntry
return self._make_method_(attr)
! raise pythoncom.com_error(details)
debug_attr_print("OLE returned ", ret)
return self._get_good_object_(ret)
# no where else to look.
! raise AttributeError("%s.%s" % (self._username_, attr))
def __setattr__(self, attr, value):
! if attr in self.__dict__: # Fast-track - if already in our dict, just make the assignment.
# XXX - should maybe check method map - if someone assigns to a method,
# it could mean something special (not sure what, tho!)
***************
*** 507,515 ****
return
# Allow property assignment.
! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, `value`))
if self._olerepr_:
# Check the "general" property map.
! if self._olerepr_.propMap.has_key(attr):
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 499,507 ----
return
# Allow property assignment.
! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, repr(value)))
if self._olerepr_:
# Check the "general" property map.
! if attr in self._olerepr_.propMap:
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 517,521 ****
return
# Check the specific "put" map.
! if self._olerepr_.propMapPut.has_key(attr):
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 509,513 ----
return
# Check the specific "put" map.
! if attr in self._olerepr_.propMapPut:
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 527,531 ****
if self.__LazyMap__(attr):
# Check the "general" property map.
! if self._olerepr_.propMap.has_key(attr):
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 519,523 ----
if self.__LazyMap__(attr):
# Check the "general" property map.
! if attr in self._olerepr_.propMap:
entry = self._olerepr_.propMap[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 533,537 ****
return
# Check the specific "put" map.
! if self._olerepr_.propMapPut.has_key(attr):
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
--- 525,529 ----
return
# Check the specific "put" map.
! if attr in self._olerepr_.propMapPut:
entry = self._olerepr_.propMapPut[attr]
invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT)
***************
*** 552,554 ****
except pythoncom.com_error:
pass
! raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr)
--- 544,546 ----
except pythoncom.com_error:
pass
! raise AttributeError("Property '%s.%s' can not be set." % (self._username_, attr))
Index: combrowse.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -d -r1.8 -r1.8.2.1
*** combrowse.py 1 Jul 2008 01:04:40 -0000 1.8
--- combrowse.py 29 Aug 2008 08:58:52 -0000 1.8.2.1
***************
*** 15,19 ****
Details
! This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
browser, and displays the objects in a hierarchical window.
--- 15,19 ----
Details
! This module allows browsing of registered Type Libraries, COM categories,
and running COM objects. The display is similar to the Pythonwin object
[...1005 lines suppressed...]
! if "app" in sys.modules:
! # do it in a window
! browser.MakeTemplate()
! browser.template.OpenObject(root)
! else:
! # list=hierlist.HierListWithItems( root, win32ui.IDB_BROWSER_HIER )
! # dlg=hierlist.HierDialog("COM Browser",list)
! dlg = browser.dynamic_browser(root)
! dlg.DoModal()
if __name__=='__main__':
! main()
!
! ni = pythoncom._GetInterfaceCount()
! ng = pythoncom._GetGatewayCount()
! if ni or ng:
! print("Warning - exiting with %d/%d objects alive" % (ni,ng))
Index: util.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/util.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** util.py 24 May 2007 13:00:03 -0000 1.3
--- util.py 29 Aug 2008 08:58:53 -0000 1.3.2.1
***************
*** 40,44 ****
def __GetIndex(self, index):
! if type(index)!=type(0): raise TypeError, "Only integer indexes are supported for enumerators"
# NOTE
# In this context, self.index is users purely as a flag to say
--- 40,44 ----
def __GetIndex(self, index):
! if type(index)!=type(0): raise TypeError("Only integer indexes are supported for enumerators")
# NOTE
# In this context, self.index is users purely as a flag to say
***************
*** 54,58 ****
if len(result):
return self._make_retval_(result[0])
! raise IndexError, "list index out of range"
def Next(self, count=1):
ret = self._oleobj_.Next(count)
--- 54,58 ----
if len(result):
return self._make_retval_(result[0])
! raise IndexError("list index out of range")
def Next(self, count=1):
ret = self._oleobj_.Next(count)
***************
*** 81,84 ****
def __iter__(self):
return self
! def next(self):
! return _get_good_object_(self._iter_.next(), resultCLSID = self.resultCLSID)
--- 81,84 ----
def __iter__(self):
return self
! def __next__(self):
! return _get_good_object_(next(self._iter_), resultCLSID = self.resultCLSID)
Index: __init__.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v
retrieving revision 1.34
retrieving revision 1.34.4.1
diff -C2 -d -r1.34 -r1.34.4.1
*** __init__.py 24 May 2005 14:30:04 -0000 1.34
--- __init__.py 29 Aug 2008 08:58:52 -0000 1.34.4.1
***************
*** 6,18 ****
# dispatch object, the known class will be used. This contrasts
# with dynamic.Dispatch behaviour, where dynamic objects are always used.
! import __builtin__
# For some bizarre reason, __builtins__ fails with attribute error on __dict__ here?
! NeedUnicodeConversions = not hasattr(__builtin__, "unicode")
! import dynamic, gencache, pythoncom
import sys
import pywintypes
! from types import TupleType
! from pywintypes import UnicodeType
_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
--- 6,19 ----
# dispatch object, the known class will be used. This contrasts
# with dynamic.Dispatch behaviour, where dynamic objects are always used.
! import builtins
# For some bizarre reason, __builtins__ fails with attribute error on __dict__ here?
! NeedUnicodeConversions = not hasattr(builtins, "unicode")
!
! import pythoncom
! from . import dynamic, gencache
import sys
import pywintypes
!
_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
***************
*** 33,37 ****
pass
if resultCLSID is not None:
! import gencache
# Attempt to load generated module support
# This may load the module, and make it available
--- 34,38 ----
pass
if resultCLSID is not None:
! from . import gencache
# Attempt to load generated module support
# This may load the module, and make it available
***************
*** 66,70 ****
if (Pathname is None and Class is None) or \
(Pathname is not None and Class is not None):
! raise ValueError, "You must specify a value for Pathname or Class, but not both."
if Class is not None:
--- 67,71 ----
if (Pathname is None and Class is None) or \
(Pathname is not None and Class is not None):
! raise ValueError
if Class is not None:
***************
*** 128,136 ****
if hasattr(target, "index"): # string like
# for now, we assume makepy for this to work.
! if not ob.__class__.__dict__.has_key("CLSID"):
# Eeek - no makepy support - try and build it.
ob = gencache.EnsureDispatch(ob)
! if not ob.__class__.__dict__.has_key("CLSID"):
! raise ValueError, "Must be a makepy-able object for this to work"
clsid = ob.CLSID
# Lots of hoops to support "demand-build" - ie, generating
--- 129,137 ----
if hasattr(target, "index"): # string like
# for now, we assume makepy for this to work.
! if "CLSID" not in ob.__class__.__dict__:
# Eeek - no makepy support - try and build it.
ob = gencache.EnsureDispatch(ob)
! if "CLSID" not in ob.__class__.__dict__:
! raise ValueError
clsid = ob.CLSID
# Lots of hoops to support "demand-build" - ie, generating
***************
*** 148,153 ****
target_clsid = mod.NamesToIIDMap.get(target)
if target_clsid is None:
! raise ValueError, "The interface name '%s' does not appear in the " \
! "same library as object '%r'" % (target, ob)
mod = gencache.GetModuleForCLSID(target_clsid)
target_class = getattr(mod, target)
--- 149,153 ----
target_clsid = mod.NamesToIIDMap.get(target)
if target_clsid is None:
! raise ValueError
mod = gencache.GetModuleForCLSID(target_clsid)
target_class = getattr(mod, target)
***************
*** 155,159 ****
target_class = getattr(target_class, "default_interface", target_class)
return target_class(ob) # auto QI magic happens
! raise ValueError, "This object can not be cast"
class Constants:
--- 155,159 ----
target_class = getattr(target_class, "default_interface", target_class)
return target_class(ob) # auto QI magic happens
! raise ValueError
class Constants:
***************
*** 164,170 ****
def __getattr__(self, a):
for d in self.__dicts__:
! if d.has_key(a):
return d[a]
! raise AttributeError, a
# And create an instance.
--- 164,170 ----
def __getattr__(self, a):
for d in self.__dicts__:
! if a in d:
return d[a]
! raise AttributeError
# And create an instance.
***************
*** 252,256 ****
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error:
! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object"
else:
disp_class = disp.__class__
--- 252,256 ----
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error:
! raise TypeError
else:
disp_class = disp.__class__
***************
*** 261,265 ****
events_class = getevents(clsid)
if events_class is None:
! raise ValueError, "This COM object does not support events."
result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_})
instance = result_class(disp._oleobj_) # This only calls the first base class __init__.
--- 261,265 ----
events_class = getevents(clsid)
if events_class is None:
! raise ValueError
result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_})
instance = result_class(disp._oleobj_) # This only calls the first base class __init__.
***************
*** 304,308 ****
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error:
! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object"
else:
disp_class = disp.__class__
--- 304,308 ----
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error:
! raise TypeError
else:
disp_class = disp.__class__
***************
*** 314,318 ****
events_class = getevents(clsid)
if events_class is None:
! raise ValueError, "This COM object does not support events."
result_class = new.classobj("COMEventClass", (events_class, user_event_class), {})
instance = result_class(disp) # This only calls the first base class __init__.
--- 314,318 ----
events_class = getevents(clsid)
if events_class is None:
! raise ValueError
result_class = new.classobj("COMEventClass", (events_class, user_event_class), {})
instance = result_class(disp) # This only calls the first base class __init__.
***************
*** 388,393 ****
app.MoveTo(point)
"""
! # XXX - to do - probably should allow "object" to already be a module object.
! import gencache
object = gencache.EnsureDispatch(object)
module = sys.modules[object.__class__.__module__]
--- 388,392 ----
app.MoveTo(point)
"""
! from . import gencache
object = gencache.EnsureDispatch(object)
module = sys.modules[object.__class__.__module__]
***************
*** 401,405 ****
struct_guid = package.RecordMap[name]
except KeyError:
! raise ValueError, "The structure '%s' is not defined in module '%s'" % (name, package)
return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid)
--- 400,404 ----
struct_guid = package.RecordMap[name]
except KeyError:
! raise ValueError
return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid)
***************
*** 416,420 ****
try:
oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch) # Must be a valid COM instance
! except pythoncom.com_error, details:
import winerror
# Some stupid objects fail here, even tho it is _already_ IDispatch!!??
--- 415,419 ----
try:
oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch) # Must be a valid COM instance
! except pythoncom.com_error as details:
import winerror
# Some stupid objects fail here, even tho it is _already_ IDispatch!!??
***************
*** 452,464 ****
args=self._prop_map_get_.get(attr)
if args is None:
! raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
return self._ApplyTypes_(*args)
def __setattr__(self, attr, value):
! if self.__dict__.has_key(attr): self.__dict__[attr] = value; return
try:
args, defArgs=self._prop_map_put_[attr]
except KeyError:
! raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
self._oleobj_.Invoke(*(args + (value,) + defArgs))
def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None):
--- 451,463 ----
args=self._prop_map_get_.get(attr)
if args is None:
! raise AttributeError
return self._ApplyTypes_(*args)
def __setattr__(self, attr, value):
! if attr in self.__dict__: self.__dict__[attr] = value; return
try:
args, defArgs=self._prop_map_put_[attr]
except KeyError:
! raise AttributeError
self._oleobj_.Invoke(*(args + (value,) + defArgs))
def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None):
***************
*** 471,476 ****
if _PyIDispatchType==type(obj):
return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions)
! elif NeedUnicodeConversions and UnicodeType==type(obj):
! return str(obj)
return obj
--- 470,475 ----
if _PyIDispatchType==type(obj):
return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions)
! ## elif NeedUnicodeConversions and UnicodeType==type(obj):
! ## return str(obj)
return obj
***************
*** 478,482 ****
if obj is None:
return None
! elif type(obj)==TupleType:
obUserNameTuple = (obUserName,) * len(obj)
resultCLSIDTuple = (resultCLSID,) * len(obj)
--- 477,481 ----
if obj is None:
return None
! elif isinstance(obj, tuple):
obUserNameTuple = (obUserName,) * len(obj)
resultCLSIDTuple = (resultCLSID,) * len(obj)
***************
*** 495,501 ****
d=self.__dict__["_dispobj_"]
if d is not None: return getattr(d, attr)
! raise AttributeError, attr
def __setattr__(self, attr, value):
! if self.__dict__.has_key(attr): self.__dict__[attr] = value; return
try:
d=self.__dict__["_dispobj_"]
--- 494,500 ----
d=self.__dict__["_dispobj_"]
if d is not None: return getattr(d, attr)
! raise AttributeError
def __setattr__(self, attr, value):
! if attr in self.__dict__: self.__dict__[attr] = value; return
try:
d=self.__dict__["_dispobj_"]
Index: build.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -C2 -d -r1.31 -r1.31.2.1
*** build.py 29 Jun 2008 23:57:20 -0000 1.31
--- build.py 29 Aug 2008 08:58:52 -0000 1.31.2.1
***************
*** 121,125 ****
else:
deleteExisting = 1 # No good to us
! if self.mapFuncs.has_key(key) or self.propMapGet.has_key(key):
newKey = "Set" + key
else:
--- 121,125 ----
else:
deleteExisting = 1 # No good to us
! if key in self.mapFuncs or key in self.propMapGet:
newKey = "Set" + key
else:
***************
*** 138,142 ****
else:
deleteExisting = 1 # No good to us
! if self.mapFuncs.has_key(key):
newKey = "Get" + key
else:
--- 138,142 ----
else:
deleteExisting = 1 # No good to us
! if key in self.mapFuncs:
newKey = "Get" + key
else:
***************
*** 257,266 ****
if typeinfo is None: return
# Loop over all methods
! for j in xrange(attr[6]):
fdesc = typeinfo.GetFuncDesc(j)
self._AddFunc_(typeinfo,fdesc,bForUser)
# Loop over all variables (ie, properties)
! for j in xrange(attr[7]):
fdesc = typeinfo.GetVarDesc(j)
self._AddVar_(typeinfo,fdesc,bForUser)
--- 257,266 ----
if typeinfo is None: return
# Loop over all methods
! for j in range(attr[6]):
fdesc = typeinfo.GetFuncDesc(j)
self._AddFunc_(typeinfo,fdesc,bForUser)
# Loop over all variables (ie, properties)
! for j in range(attr[7]):
fdesc = typeinfo.GetVarDesc(j)
self._AddVar_(typeinfo,fdesc,bForUser)
***************
*** 269,276 ****
# that have arguments, we must turn them into methods. If a method
# of the same name already exists, change the name.
! for key, item in self.propMapGet.items():
self._propMapGetCheck_(key,item)
! for key, item in self.propMapPut.items():
self._propMapPutCheck_(key,item)
--- 269,276 ----
# that have arguments, we must turn them into methods. If a method
# of the same name already exists, change the name.
! for key, item in list(self.propMapGet.items()):
self._propMapGetCheck_(key,item)
! for key, item in list(self.propMapPut.items()):
self._propMapPutCheck_(key,item)
***************
*** 316,319 ****
--- 316,320 ----
defOutArg = "pythoncom.Missing"
id = fdesc[0]
+
s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):'
ret.append(s)
***************
*** 330,347 ****
# Strip the default values from the arg desc
retDesc = fdesc[8][:2]
! argsDesc = tuple(map(lambda what: what[:2], fdesc[2]))
# The runtime translation of the return types is expensive, so when we know the
# return type of the function, there is no need to check the type at runtime.
# To qualify, this function must return a "simple" type, and have no byref args.
# Check if we have byrefs or anything in the args which mean we still need a translate.
! param_flags = map(lambda what: what[1], fdesc[2])
! bad_params = filter(lambda flag: flag & (pythoncom.PARAMFLAG_FOUT | pythoncom.PARAMFLAG_FRETVAL)!=0, param_flags)
s = None
if len(bad_params)==0 and len(retDesc)==2 and retDesc[1]==0:
rd = retDesc[0]
! if NoTranslateMap.has_key(rd):
s = '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, _BuildArgList(fdesc, names))
elif rd in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN]:
! s = '%s\tret = self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)\n' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names))
s = s + '%s\tif ret is not None:\n' % (linePrefix,)
if rd == pythoncom.VT_UNKNOWN:
--- 331,348 ----
# Strip the default values from the arg desc
retDesc = fdesc[8][:2]
! argsDesc = tuple([what[:2] for what in fdesc[2]])
# The runtime translation of the return types is expensive, so when we know the
# return type of the function, there is no need to check the type at runtime.
# To qualify, this function must return a "simple" type, and have no byref args.
# Check if we have byrefs or anything in the args which mean we still need a translate.
! param_flags = [what[1] for what in fdesc[2]]
! bad_params = [flag for flag in param_flags if flag & (pythoncom.PARAMFLAG_FOUT | pythoncom.PARAMFLAG_FRETVAL)!=0]
s = None
if len(bad_params)==0 and len(retDesc)==2 and retDesc[1]==0:
rd = retDesc[0]
! if rd in NoTranslateMap:
s = '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, _BuildArgList(fdesc, names))
elif rd in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN]:
! s = '%s\tret = self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)\n' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
s = s + '%s\tif ret is not None:\n' % (linePrefix,)
if rd == pythoncom.VT_UNKNOWN:
***************
*** 351,366 ****
s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,)
s = s + "%s\t\t\treturn ret\n" % (linePrefix,)
! s = s + '%s\t\tret = Dispatch(ret, %s, %s, UnicodeToString=%d)\n' % (linePrefix,`name`, resclsid, NeedUnicodeConversions)
s = s + '%s\treturn ret' % (linePrefix)
elif rd == pythoncom.VT_BSTR:
if NeedUnicodeConversions:
s = "%s\t# Result is a Unicode object - perform automatic string conversion\n" % (linePrefix,)
! s = s + '%s\treturn str(self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s))' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names))
else:
s = "%s\t# Result is a Unicode object - return as-is for this version of Python\n" % (linePrefix,)
! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names))
# else s remains None
if s is None:
! s = '%s\treturn self._ApplyTypes_(%d, %s, %s, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, `name`, resclsid, _BuildArgList(fdesc, names))
ret.append(s)
--- 352,367 ----
s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,)
s = s + "%s\t\t\treturn ret\n" % (linePrefix,)
! s = s + '%s\t\tret = Dispatch(ret, %s, %s, UnicodeToString=%d)\n' % (linePrefix,repr(name), resclsid, NeedUnicodeConversions)
s = s + '%s\treturn ret' % (linePrefix)
elif rd == pythoncom.VT_BSTR:
if NeedUnicodeConversions:
s = "%s\t# Result is a Unicode object - perform automatic string conversion\n" % (linePrefix,)
! s = s + '%s\treturn str(self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s))' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
else:
s = "%s\t# Result is a Unicode object - return as-is for this version of Python\n" % (linePrefix,)
! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names))
# else s remains None
if s is None:
! s = '%s\treturn self._ApplyTypes_(%d, %s, %s, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, repr(name), resclsid, _BuildArgList(fdesc, names))
ret.append(s)
***************
*** 395,404 ****
assert typeinfo is not None, "Cant build vtables without type info!"
! def cmp_vtable_off(m1, m2):
! return cmp(m1.desc[7], m2.desc[7])
! meth_list = self.mapFuncs.values() + self.propMapGet.values() + self.propMapPut.values()
! meth_list.sort( cmp_vtable_off )
# Now turn this list into the run-time representation
# (ready for immediate use or writing to gencache)
--- 396,405 ----
assert typeinfo is not None, "Cant build vtables without type info!"
! def cmp_vtable_off(m1):
! return m1.desc[7]
! meth_list = list(self.mapFuncs.values()) + list(self.propMapGet.values()) + list(self.propMapPut.values())
! meth_list.sort(key = cmp_vtable_off )
# Now turn this list into the run-time representation
# (ready for immediate use or writing to gencache)
***************
*** 425,429 ****
# Resolve VT_USERDEFINED (often aliases or typed IDispatches)
! if type(typerepr)==types.TupleType:
indir_vt, subrepr = typerepr
if indir_vt == pythoncom.VT_PTR:
--- 426,430 ----
# Resolve VT_USERDEFINED (often aliases or typed IDispatches)
! if type(typerepr)==tuple:
indir_vt, subrepr = typerepr
if indir_vt == pythoncom.VT_PTR:
***************
*** 435,439 ****
# only when "somehandle" is an object.
# but (VT_PTR, (VT_USERDEFINED, otherhandle)) doesnt get the indirection dropped.
! was_user = type(subrepr)==types.TupleType and subrepr[0]==pythoncom.VT_USERDEFINED
subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo)
if was_user and subrepr in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN, pythoncom.VT_RECORD]:
--- 436,440 ----
# only when "somehandle" is an object.
# but (VT_PTR, (VT_USERDEFINED, otherhandle)) doesnt get the indirection dropped.
! was_user = type(subrepr)==tuple and subrepr[0]==pythoncom.VT_USERDEFINED
subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo)
if was_user and subrepr in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN, pythoncom.VT_RECORD]:
***************
*** 453,457 ****
try:
resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr)
! except pythoncom.com_error, details:
if details[0] in [winerror.TYPE_E_CANTLOADLIBRARY,
winerror.TYPE_E_LIBNOTREGISTERED]:
--- 454,458 ----
try:
resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr)
! except pythoncom.com_error as details:
if details[0] in [winerror.TYPE_E_CANTLOADLIBRARY,
winerror.TYPE_E_LIBNOTREGISTERED]:
***************
*** 494,498 ****
i = names.index(None)
names[i] = "arg%d" % (i,)
! names = map(MakePublicAttributeName, names[1:])
name_num = 0
while len(names) < numArgs:
--- 495,499 ----
i = names.index(None)
names[i] = "arg%d" % (i,)
! names = list(map(MakePublicAttributeName, names[1:]))
name_num = 0
while len(names) < numArgs:
***************
*** 503,507 ****
for i in range(0, len(names), 5):
names[i] = names[i] + "\n\t\t\t"
! return "," + string.join(names, ", ")
valid_identifier_chars = string.ascii_letters + string.digits + "_"
--- 504,508 ----
for i in range(0, len(names), 5):
names[i] = names[i] + "\n\t\t\t"
! return "," + ", ".join(names)
valid_identifier_chars = string.ascii_letters + string.digits + "_"
***************
*** 527,536 ****
return demunge_leading_underscores(className)
elif iskeyword(className): # all keywords are lower case
! return string.capitalize(className)
elif className == 'None':
# assign to None is evil (and SyntaxError in 2.4) - note
# that if it was a global it would get picked up below
className = 'NONE'
! elif is_global and __builtins__.has_key(className):
# builtins may be mixed case. If capitalizing it doesn't change it,
# force to all uppercase (eg, "None", "True" become "NONE", "TRUE"
--- 528,537 ----
return demunge_leading_underscores(className)
elif iskeyword(className): # all keywords are lower case
! return className.capitalize()
elif className == 'None':
# assign to None is evil (and SyntaxError in 2.4) - note
# that if it was a global it would get picked up below
className = 'NONE'
! elif is_global and className in __builtins__:
# builtins may be mixed case. If capitalizing it doesn't change it,
# force to all uppercase (eg, "None", "True" become "NONE", "TRUE"
***************
*** 540,544 ****
return ret
# Strip non printable chars
! return filter( lambda char: char in valid_identifier_chars, className)
# Given a default value passed by a type library, return a string with
--- 541,545 ----
return ret
# Strip non printable chars
! return ''.join([char for char in className if char in valid_identifier_chars])
# Given a default value passed by a type library, return a string with
***************
*** 577,581 ****
else:
firstOptArg = numArgs - numOptArgs
! for arg in xrange(numArgs):
try:
argName = names[arg+1]
--- 578,582 ----
else:
firstOptArg = numArgs - numOptArgs
! for arg in range(numArgs):
try:
argName = names[arg+1]
***************
*** 603,606 ****
--- 604,608 ----
argName = MakePublicAttributeName(argName)
+
# insanely long lines with an 'encoding' flag crashes python 2.4.0
# keep 5 args per line
***************
*** 622,624 ****
if __name__=='__main__':
! print "Use 'makepy.py' to generate Python code - this module is just a helper"
--- 624,626 ----
if __name__=='__main__':
! print("Use 'makepy.py' to generate Python code - this module is just a helper")
Index: genpy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v
retrieving revision 1.55
retrieving revision 1.55.2.1
diff -C2 -d -r1.55 -r1.55.2.1
*** genpy.py 1 Jul 2008 00:11:14 -0000 1.55
--- genpy.py 29 Aug 2008 08:58:53 -0000 1.55.2.1
***************
*** 16,28 ****
import os
import sys
- import string
import time
import win32com
import pythoncom
! import build
error = "makepy.error"
[...1167 lines suppressed...]
def checkWriteDispatchBaseClass(self):
if not self.bHaveWrittenDispatchBaseClass:
! print("from win32com.client import DispatchBaseClass", file=self.file)
self.bHaveWrittenDispatchBaseClass = 1
def checkWriteCoClassBaseClass(self):
if not self.bHaveWrittenCoClassBaseClass:
! print("from win32com.client import CoClassBaseClass", file=self.file)
self.bHaveWrittenCoClassBaseClass = 1
***************
*** 1024,1026 ****
if __name__=='__main__':
! print "This is a worker module. Please use makepy to generate Python files."
--- 1021,1023 ----
if __name__=='__main__':
! print("This is a worker module. Please use makepy to generate Python files.")
Index: gencache.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v
retrieving revision 1.32
retrieving revision 1.32.2.1
diff -C2 -d -r1.32 -r1.32.2.1
*** gencache.py 22 Jan 2007 22:18:44 -0000 1.32
--- gencache.py 29 Aug 2008 08:58:53 -0000 1.32.2.1
***************
*** 21,30 ****
Maybe an OLE2 compound file, or a bsddb file?
"""
! import pywintypes, os, string, sys
import pythoncom
import win32com, win32com.client
import glob
import traceback
! import CLSIDToClass
import operator
--- 21,30 ----
Maybe an OLE2 compound file, or a bsddb file?
"""
! import pywintypes, os, sys
import pythoncom
import win32com, win32com.client
import glob
import traceback
! from . import CLSIDToClass
import operator
***************
*** 59,68 ****
def _SaveDicts():
if is_readonly:
! raise RuntimeError, "Trying to write to a readonly gencache ('%s')!" \
! % win32com.__gen_path__
! import cPickle
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
try:
! p = cPickle.Pickler(f)
p.dump(pickleVersion)
p.dump(clsidToTypelib)
--- 59,68 ----
def _SaveDicts():
if is_readonly:
! raise RuntimeError("Trying to write to a readonly gencache ('%s')!" \
! % win32com.__gen_path__)
! import pickle
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
try:
! p = pickle.Pickler(f)
p.dump(pickleVersion)
p.dump(clsidToTypelib)
***************
*** 71,78 ****
def _LoadDicts():
! import cPickle
# Load the dictionary from a .zip file if that is where we live.
if hasattr(win32com, "__loader__"):
! import cStringIO
loader = win32com.__loader__
arc_path = loader.archive
--- 71,78 ----
def _LoadDicts():
! import pickle
# Load the dictionary from a .zip file if that is where we live.
if hasattr(win32com, "__loader__"):
! import io
loader = win32com.__loader__
arc_path = loader.archive
***************
*** 101,110 ****
# the dict)
return
! f = cStringIO.StringIO(data)
else:
# NOTE: IOError on file open must be caught by caller.
f = open(os.path.join(win32com.__gen_path__, "dicts.dat"), "rb")
try:
! p = cPickle.Unpickler(f)
version = p.load()
global clsidToTypelib
--- 101,110 ----
# the dict)
return
! f = io.StringIO(data)
else:
# NOTE: IOError on file open must be caught by caller.
f = open(os.path.join(win32com.__gen_path__, "dicts.dat"), "rb")
try:
! p = pickle.Unpickler(f)
version = p.load()
global clsidToTypelib
***************
*** 118,127 ****
the file name (no extension) providing this support.
"""
! return string.upper(str(clsid))[1:-1] + "x%sx%sx%s" % (lcid, major, minor)
def SplitGeneratedFileName(fname):
"""Reverse of GetGeneratedFileName()
"""
! return tuple(string.split(fname,'x',4))
def GetGeneratePath():
--- 118,127 ----
the file name (no extension) providing this support.
"""
! return str(clsid).upper()[1:-1] + "x%sx%sx%s" % (lcid, major, minor)
def SplitGeneratedFileName(fname):
"""Reverse of GetGeneratedFileName()
"""
! return tuple(fname.split('x',4))
def GetGeneratePath():
***************
*** 235,241 ****
# Force the generation. If this typelibrary has explicitly been added,
# use it (it may not be registered, causing a lookup by clsid to fail)
! if demandGeneratedTypeLibraries.has_key(info):
info = demandGeneratedTypeLibraries[info]
! import makepy
makepy.GenerateChildFromTypeLibSpec(sub_mod, info)
# Generate does an import...
--- 235,241 ----
# Force the generation. If this typelibrary has explicitly been added,
# use it (it may not be registered, causing a lookup by clsid to fail)
! if info in demandGeneratedTypeLibraries:
info = demandGeneratedTypeLibraries[info]
! from . import makepy
makepy.GenerateChildFromTypeLibSpec(sub_mod, info)
# Generate does an import...
***************
*** 259,265 ****
# If the import worked, it doesn't mean we have actually added this
# module to our cache though - check that here.
! if not mod.__dict__.has_key("_in_gencache_"):
AddModuleToCache(typelibCLSID, lcid, major, minor)
! assert mod.__dict__.has_key("_in_gencache_")
return mod
--- 259,265 ----
# If the import worked, it doesn't mean we have actually added this
# module to our cache though - check that here.
! if "_in_gencache_" not in mod.__dict__:
AddModuleToCache(typelibCLSID, lcid, major, minor)
! assert "_in_gencache_" in mod.__dict__
return mod
***************
*** 281,287 ****
"""
if bGUIProgress is not None:
! print "The 'bGuiProgress' param to 'MakeModuleForTypelib' is obsolete."
! import makepy
try:
makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
--- 281,287 ----
"""
if bGUIProgress is not None:
! print("The 'bGuiProgress' param to 'MakeModuleForTypelib' is obsolete.")
! from . import makepy
try:
makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
***************
*** 304,308 ****
use the GUI progress bar.
"""
! import makepy
try:
makepy.GenerateFromTypeLibSpec( typelib_ob, progressInstance=progressInstance, bForDemand = bForDemandDefault, bBuildHidden = bBuildHidden)
--- 304,308 ----
use the GUI progress bar.
"""
! from . import makepy
try:
makepy.GenerateFromTypeLibSpec( typelib_ob, progressInstance=progressInstance, bForDemand = bForDemandDefault, bBuildHidden = bBuildHidden)
***************
*** 360,366 ****
except KeyError:
# Not worth raising an exception - maybe they dont know we only remember for demand generated, etc.
! print "ForgetAboutTypelibInterface:: Warning - type library with info %s is not being remembered!" % (info,)
# and drop any version redirects to it
! for key, val in versionRedirectMap.items():
if val==info:
del versionRedirectMap[key]
--- 360,366 ----
except KeyError:
# Not worth raising an exception - maybe they dont know we only remember for demand generated, etc.
! print("ForgetAboutTypelibInterface:: Warning - type library with info %s is not being remembered!" % (info,))
# and drop any version redirects to it
! for key, val in list(versionRedirectMap.items()):
if val==info:
del versionRedirectMap[key]
***************
*** 446,450 ****
# Verify that type library is up to date.
# If we have a differing MinorVersion or genpy has bumped versions, update the file
! import genpy
if module.MinorVersion != tlbAttributes[4] or genpy.makepy_version != module.makepy_version:
#print "Version skew: %d, %d" % (module.MinorVersion, tlbAttributes[4])
--- 446,450 ----
# Verify that type library is up to date.
# If we have a differing MinorVersion or genpy has bumped versions, update the file
! from . import genpy
if module.MinorVersion != tlbAttributes[4] or genpy.makepy_version != module.makepy_version:
#print "Version skew: %d, %d" % (module.MinorVersion, tlbAttributes[4])
***************
*** 474,478 ****
pyModTime = os.stat(filePath)[8]
fModTimeSet = 1
! except os.error, e:
# If .py file fails, try .pyc file
#print "Trying pyc stat", filePathPyc
--- 474,478 ----
pyModTime = os.stat(filePath)[8]
fModTimeSet = 1
! except os.error as e:
# If .py file fails, try .pyc file
#print "Trying pyc stat", filePathPyc
***************
*** 480,484 ****
pyModTime = os.stat(filePathPyc)[8]
fModTimeSet = 1
! except os.error, e:
pass
#print "Trying stat typelib", pyModTime
--- 480,484 ----
pyModTime = os.stat(filePathPyc)[8]
fModTimeSet = 1
! except os.error as e:
pass
#print "Trying stat typelib", pyModTime
***************
*** 536,545 ****
mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand)
GetModuleForCLSID(disp_clsid)
! # Get the class from the module.
! import CLSIDToClass
disp_class = CLSIDToClass.GetClass(str(disp_clsid))
disp = disp_class(disp._oleobj_)
except pythoncom.com_error:
! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object"
return disp
--- 536,544 ----
mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand)
GetModuleForCLSID(disp_clsid)
! from . import CLSIDToClass
disp_class = CLSIDToClass.GetClass(str(disp_clsid))
disp = disp_class(disp._oleobj_)
except pythoncom.com_error:
! raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object")
return disp
***************
*** 554,574 ****
dict = mod.CLSIDToClassMap
info = str(typelibclsid), lcid, major, minor
! for clsid, cls in dict.items():
clsidToTypelib[clsid] = info
dict = mod.CLSIDToPackageMap
! for clsid, name in dict.items():
clsidToTypelib[clsid] = info
dict = mod.VTablesToClassMap
! for clsid, cls in dict.items():
clsidToTypelib[clsid] = info
dict = mod.VTablesToPackageMap
! for clsid, cls in dict.items():
clsidToTypelib[clsid] = info
# If this lib was previously redirected, drop it
! if versionRedirectMap.has_key(info):
del versionRedirectMap[info]
if bFlushNow:
--- 553,573 ----
dict = mod.CLSIDToClassMap
info = str(typelibclsid), lcid, major, minor
! for clsid, cls in list(dict.items()):
clsidToTypelib[clsid] = ...
[truncated message content] |