home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import __builtin__
- NeedUnicodeConversions = not hasattr(__builtin__, 'unicode')
- import dynamic
- import gencache
- import pythoncom
- import sys
- import pywintypes
- from types import TupleType
- from pywintypes import UnicodeType
- _PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]
-
- def __WrapDispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER, WrapperClass = None):
- if resultCLSID is None:
-
- try:
- typeinfo = dispatch.GetTypeInfo()
- if typeinfo is not None:
- resultCLSID = str(typeinfo.GetTypeAttr()[0])
- except (pythoncom.com_error, AttributeError):
- pass
- except:
- None<EXCEPTION MATCH>(pythoncom.com_error, AttributeError)
-
-
- None<EXCEPTION MATCH>(pythoncom.com_error, AttributeError)
- if resultCLSID is not None:
- import gencache
- klass = gencache.GetClassForCLSID(resultCLSID)
- if klass is not None:
- return klass(dispatch)
-
- if WrapperClass is None:
- WrapperClass = CDispatch
-
- return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString = UnicodeToString, clsctx = clsctx)
-
-
- def GetObject(Pathname = None, Class = None, clsctx = None):
- if clsctx is None:
- clsctx = pythoncom.CLSCTX_ALL
-
- if (Pathname is None or 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.'
- Class is not None
- if Class is not None:
- return GetActiveObject(Class, clsctx)
- return Moniker(Pathname, clsctx)
-
-
- def GetActiveObject(Class, clsctx = pythoncom.CLSCTX_ALL):
- resultCLSID = pywintypes.IID(Class)
- dispatch = pythoncom.GetActiveObject(resultCLSID)
- dispatch = dispatch.QueryInterface(pythoncom.IID_IDispatch)
- return __WrapDispatch(dispatch, Class, resultCLSID = resultCLSID, clsctx = clsctx)
-
-
- def Moniker(Pathname, clsctx = pythoncom.CLSCTX_ALL):
- (moniker, i, bindCtx) = pythoncom.MkParseDisplayName(Pathname)
- dispatch = moniker.BindToObject(bindCtx, None, pythoncom.IID_IDispatch)
- return __WrapDispatch(dispatch, Pathname, clsctx = clsctx)
-
-
- def Dispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER):
- (dispatch, userName) = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
- return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
-
-
- def DispatchEx(clsid, machine = None, userName = None, resultCLSID = None, typeinfo = None, UnicodeToString = NeedUnicodeConversions, clsctx = None):
- if clsctx is None:
- clsctx = pythoncom.CLSCTX_SERVER
- if machine is not None:
- clsctx = clsctx & ~(pythoncom.CLSCTX_INPROC)
-
-
- if machine is None:
- serverInfo = None
- else:
- serverInfo = (machine,)
- if userName is None:
- userName = clsid
-
- dispatch = pythoncom.CoCreateInstanceEx(clsid, None, clsctx, serverInfo, (pythoncom.IID_IDispatch,))[0]
- return Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString = UnicodeToString, clsctx = clsctx)
-
-
- class CDispatch(dynamic.CDispatch):
-
- def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString = NeedUnicodeConversions):
- return Dispatch(ob, userName, returnCLSID, None, UnicodeToString)
-
-
-
- def CastTo(ob, target):
- if hasattr(target, 'index'):
- if not ob.__class__.__dict__.has_key('CLSID'):
- ob = gencache.EnsureDispatch(ob)
-
- if not ob.__class__.__dict__.has_key('CLSID'):
- raise ValueError, 'Must be a makepy-able object for this to work'
- ob.__class__.__dict__.has_key('CLSID')
- clsid = ob.CLSID
- mod = gencache.GetModuleForCLSID(clsid)
- mod = gencache.GetModuleForTypelib(mod.CLSID, mod.LCID, mod.MajorVersion, mod.MinorVersion)
- 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)
- target_clsid is None
- mod = gencache.GetModuleForCLSID(target_clsid)
- target_class = getattr(mod, target)
- target_class = getattr(target_class, 'default_interface', target_class)
- return target_class(ob)
- raise ValueError, 'This object can not be cast'
-
-
- class Constants:
-
- def __init__(self):
- self.__dicts__ = []
-
-
- def __getattr__(self, a):
- for d in self.__dicts__:
- if d.has_key(a):
- return d[a]
-
- raise AttributeError, a
-
-
- constants = Constants()
-
- def _event_setattr_(self, attr, val):
-
- try:
- self.__class__.__bases__[0].__setattr__(self, attr, val)
- except AttributeError:
- self.__dict__[attr] = val
-
-
-
- class EventsProxy:
-
- def __init__(self, ob):
- self.__dict__['_obj_'] = ob
-
-
- def __del__(self):
-
- try:
- self._obj_.close()
- except pythoncom.com_error:
- pass
-
-
-
- def __getattr__(self, attr):
- return getattr(self._obj_, attr)
-
-
- def __setattr__(self, attr, val):
- setattr(self._obj_, attr, val)
-
-
-
- def DispatchWithEvents(clsid, user_event_class):
- disp = Dispatch(clsid)
- if not disp.__class__.__dict__.get('CLSID'):
-
- try:
- ti = disp._oleobj_.GetTypeInfo()
- disp_clsid = ti.GetTypeAttr()[0]
- (tlb, index) = ti.GetContainingTypeLib()
- tla = tlb.GetLibAttr()
- gencache.EnsureModule(tla[0], tla[1], tla[3], tla[4], bValidateFile = 0)
- 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'
- except:
- None<EXCEPTION MATCH>pythoncom.com_error
-
-
- None<EXCEPTION MATCH>pythoncom.com_error
- disp_class = disp.__class__
- clsid = disp_class.CLSID
- import new
- events_class = getevents(clsid)
- if events_class is None:
- raise ValueError, 'This COM object does not support events.'
- events_class is None
- result_class = new.classobj('COMEventClass', (disp_class, events_class, user_event_class), {
- '__setattr__': _event_setattr_ })
- instance = result_class(disp._oleobj_)
- events_class.__init__(instance, instance)
- if hasattr(user_event_class, '__init__'):
- user_event_class.__init__(instance)
-
- return EventsProxy(instance)
-
-
- def WithEvents(disp, user_event_class):
- disp = Dispatch(disp)
- if not disp.__class__.__dict__.get('CLSID'):
-
- try:
- ti = disp._oleobj_.GetTypeInfo()
- disp_clsid = ti.GetTypeAttr()[0]
- (tlb, index) = ti.GetContainingTypeLib()
- tla = tlb.GetLibAttr()
- gencache.EnsureModule(tla[0], tla[1], tla[3], tla[4], bValidateFile = 0)
- 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'
- except:
- None<EXCEPTION MATCH>pythoncom.com_error
-
-
- None<EXCEPTION MATCH>pythoncom.com_error
- disp_class = disp.__class__
- clsid = disp_class.CLSID
- import new
- events_class = getevents(clsid)
- if events_class is None:
- raise ValueError, 'This COM object does not support events.'
- events_class is None
- result_class = new.classobj('COMEventClass', (events_class, user_event_class), { })
- instance = result_class(disp)
- if hasattr(user_event_class, '__init__'):
- user_event_class.__init__(instance)
-
- return instance
-
-
- def getevents(clsid):
- clsid = str(pywintypes.IID(clsid))
- klass = gencache.GetClassForCLSID(clsid)
-
- try:
- return klass.default_source
- except AttributeError:
-
- try:
- return gencache.GetClassForCLSID(klass.coclass_clsid).default_source
- except AttributeError:
- return None
-
-
- None<EXCEPTION MATCH>AttributeError
-
-
-
- def Record(name, object):
- import gencache
- object = gencache.EnsureDispatch(object)
- module = sys.modules[object.__class__.__module__]
- package = gencache.GetModuleForTypelib(module.CLSID, module.LCID, module.MajorVersion, module.MinorVersion)
-
- try:
- 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)
-
-
- class DispatchBaseClass:
-
- def __init__(self, oobj = None):
- if oobj is None:
- oobj = pythoncom.new(self.CLSID)
- elif type(self) == type(oobj):
-
- try:
- oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch)
- except pythoncom.com_error:
- details = None
- import winerror
- if details[0] != winerror.E_NOINTERFACE:
- raise
- details[0] != winerror.E_NOINTERFACE
- oobj = oobj._oleobj_
- except:
- None<EXCEPTION MATCH>pythoncom.com_error
-
-
- None<EXCEPTION MATCH>pythoncom.com_error
- self.__dict__['_oleobj_'] = oobj
-
-
- def __repr__(self):
-
- try:
- mod_doc = sys.modules[self.__class__.__module__].__doc__
- if mod_doc:
- mod_name = 'win32com.gen_py.' + mod_doc
- else:
- mod_name = sys.modules[self.__class__.__module__].__name__
- except KeyError:
- mod_name = 'win32com.gen_py.unknown'
-
- return '<%s.%s instance at 0x%s>' % (mod_name, self.__class__.__name__, id(self))
-
-
- def __cmp__(self, other):
- other = getattr(other, '_oleobj_', other)
- return cmp(self._oleobj_, other)
-
-
- def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args):
- return self._get_good_object_(self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), user, resultCLSID)
-
-
- def __getattr__(self, attr):
- args = self._prop_map_get_.get(attr)
- if args is None:
- raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
- args is None
- return self._ApplyTypes_(*args)
-
-
- def __setattr__(self, attr, value):
- if self.__dict__.has_key(attr):
- self.__dict__[attr] = value
- return None
-
- try:
- (args, defArgs) = self._prop_map_put_[attr]
- except KeyError:
- self.__dict__.has_key(attr)
- self.__dict__.has_key(attr)
- raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr)
- except:
- self.__dict__.has_key(attr)
-
- self._oleobj_.Invoke(*args + (value,) + defArgs)
-
-
- def _get_good_single_object_(self, obj, obUserName = None, resultCLSID = None):
- return _get_good_single_object_(obj, obUserName, resultCLSID)
-
-
- def _get_good_object_(self, obj, obUserName = None, resultCLSID = None):
- return _get_good_object_(obj, obUserName, resultCLSID)
-
-
-
- def _get_good_single_object_(obj, obUserName = None, resultCLSID = None):
- if _PyIDispatchType == type(obj):
- return Dispatch(obj, obUserName, resultCLSID, UnicodeToString = NeedUnicodeConversions)
- if NeedUnicodeConversions and UnicodeType == type(obj):
- return str(obj)
- return obj
-
-
- def _get_good_object_(obj, obUserName = None, resultCLSID = None):
- if obj is None:
- return None
- if type(obj) == TupleType:
- obUserNameTuple = (obUserName,) * len(obj)
- resultCLSIDTuple = (resultCLSID,) * len(obj)
- return tuple(map(_get_good_object_, obj, obUserNameTuple, resultCLSIDTuple))
- return _get_good_single_object_(obj, obUserName, resultCLSID)
-
-
- class CoClassBaseClass:
-
- def __init__(self, oobj = None):
- if oobj is None:
- oobj = pythoncom.new(self.CLSID)
-
- self.__dict__['_dispobj_'] = self.default_interface(oobj)
-
-
- def __repr__(self):
- return '<win32com.gen_py.%s.%s>' % (__doc__, self.__class__.__name__)
-
-
- def __getattr__(self, attr):
- 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 None
-
- try:
- d = self.__dict__['_dispobj_']
- if d is not None:
- d.__setattr__(attr, value)
- return None
- except AttributeError:
- self.__dict__.has_key(attr)
- self.__dict__.has_key(attr)
- except:
- self.__dict__.has_key(attr)
-
- self.__dict__[attr] = value
-
-
-