Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27242/com/win32com/client
Modified Files:
makepy.py
Log Message:
Allow GetTypeLibsForSpec (and therefore the makepy cmdline) to accept
a ProgID of a COM object along with a typelib spec)
Index: makepy.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** makepy.py 12 Jul 2006 12:39:28 -0000 1.22
--- makepy.py 28 Mar 2007 12:34:51 -0000 1.23
***************
*** 70,74 ****
import selecttlb
import gencache
! from win32com.client import NeedUnicodeConversions
bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py
--- 70,74 ----
import selecttlb
import gencache
! from win32com.client import NeedUnicodeConversions, Dispatch
bForDemandDefault = 0 # Default value of bForDemand - toggle this to change the world - see also gencache.py
***************
*** 164,170 ****
def GetTypeLibsForSpec(arg):
! """Given an argument on the command line (either a file name or a library description)
! return a list of actual typelibs to use.
! """
typelibs = []
try:
--- 164,170 ----
def GetTypeLibsForSpec(arg):
! """Given an argument on the command line (either a file name, library
! description, or ProgID of an object) return a list of actual typelibs
! to use. """
typelibs = []
try:
***************
*** 178,181 ****
--- 178,192 ----
tlbs = selecttlb.FindTlbsWithDescription(arg)
if len(tlbs)==0:
+ # Maybe it is the name of a COM object?
+ try:
+ ob = Dispatch(arg)
+ # and if so, it must support typelib info
+ tlb, index = ob._oleobj_.GetTypeInfo().GetContainingTypeLib()
+ spec = selecttlb.TypelibSpec(None, 0,0,0)
+ spec.FromTypelib(tlb)
+ tlbs.append(spec)
+ except pythoncom.com_error:
+ pass
+ if len(tlbs)==0:
print "Could not locate a type library matching '%s'" % (arg)
for spec in tlbs:
|