comtypes 1.4.7__zip → 1.4.9__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. {comtypes-1.4.7 → comtypes-1.4.9}/CHANGES.txt +39 -0
  2. {comtypes-1.4.7/comtypes.egg-info → comtypes-1.4.9}/PKG-INFO +6 -4
  3. {comtypes-1.4.7 → comtypes-1.4.9}/README.md +5 -3
  4. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/GUID.py +6 -5
  5. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/__init__.py +16 -5
  6. comtypes-1.4.9/comtypes/_comobject.py +507 -0
  7. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_memberspec.py +81 -9
  8. comtypes-1.4.9/comtypes/_meta.py +95 -0
  9. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_npsupport.py +2 -1
  10. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/__init__.py +1 -0
  11. comtypes-1.4.9/comtypes/_post_coinit/_cominterface_meta_patcher.py +153 -0
  12. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/misc.py +21 -40
  13. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/unknwn.py +88 -209
  14. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_safearray.py +1 -2
  15. comtypes-1.4.9/comtypes/_vtbl.py +448 -0
  16. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/automation.py +36 -45
  17. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/__init__.py +21 -31
  18. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_code_cache.py +5 -4
  19. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_constants.py +1 -1
  20. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_events.py +1 -2
  21. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/_generate.py +9 -13
  22. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/lazybind.py +2 -7
  23. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/errorinfo.py +3 -3
  24. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/git.py +2 -2
  25. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hints.pyi +11 -19
  26. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/persist.py +7 -7
  27. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/safearray.py +12 -6
  28. comtypes-1.4.9/comtypes/server/__init__.py +86 -0
  29. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/inprocserver.py +22 -17
  30. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/localserver.py +28 -16
  31. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/register.py +62 -73
  32. comtypes-1.4.9/comtypes/server/w_getopt.py +48 -0
  33. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/shelllink.py +49 -67
  34. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.py +1 -1
  35. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.py +1 -1
  36. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/__init__.py +9 -12
  37. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/find_memleak.py +0 -1
  38. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_BSTR.py +4 -7
  39. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_agilent.py +0 -1
  40. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_avmc.py +1 -1
  41. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_casesensitivity.py +3 -5
  42. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_clear_cache.py +1 -0
  43. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_collections.py +3 -3
  44. comtypes-1.4.9/comtypes/test/test_comobject.py +146 -0
  45. comtypes-1.4.9/comtypes/test/test_comserver.py +319 -0
  46. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_createwrappers.py +2 -6
  47. comtypes-1.4.9/comtypes/test/test_dispinterface.py +153 -0
  48. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_excel.py +22 -13
  49. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ie.py +2 -5
  50. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_inout_args.py +8 -5
  51. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_midl_safearray_create.py +9 -1
  52. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_outparam.py +17 -10
  53. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_safearray.py +1 -90
  54. comtypes-1.4.9/comtypes/test/test_server.py +350 -0
  55. comtypes-1.4.9/comtypes/test/test_server_register.py +536 -0
  56. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_shelllink.py +10 -14
  57. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_showevents.py +7 -17
  58. comtypes-1.4.9/comtypes/test/test_stream.py +131 -0
  59. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeannotator.py +1 -1
  60. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_urlhistory.py +1 -0
  61. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_variant.py +0 -19
  62. comtypes-1.4.9/comtypes/test/test_w_getopt.py +29 -0
  63. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_win32com_interop.py +80 -36
  64. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_wmi.py +0 -3
  65. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/codegenerator.py +62 -68
  66. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/helpers.py +8 -8
  67. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/namespaces.py +97 -27
  68. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/packing.py +4 -4
  69. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/typeannotator.py +9 -11
  70. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/tlbparser.py +33 -32
  71. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc.py +3 -8
  72. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/typeinfo.py +32 -47
  73. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/util.py +1 -0
  74. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/viewobject.py +1 -5
  75. {comtypes-1.4.7 → comtypes-1.4.9/comtypes.egg-info}/PKG-INFO +6 -4
  76. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/SOURCES.txt +6 -3
  77. comtypes-1.4.9/pyproject.toml +55 -0
  78. comtypes-1.4.7/comtypes/_comobject.py +0 -834
  79. comtypes-1.4.7/comtypes/_idl_stuff.py +0 -67
  80. comtypes-1.4.7/comtypes/_meta.py +0 -70
  81. comtypes-1.4.7/comtypes/server/__init__.py +0 -69
  82. comtypes-1.4.7/comtypes/server/w_getopt.py +0 -75
  83. comtypes-1.4.7/comtypes/test/test_comserver.py +0 -239
  84. comtypes-1.4.7/comtypes/test/test_dispinterface.py +0 -138
  85. comtypes-1.4.7/comtypes/test/test_propputref.py +0 -40
  86. comtypes-1.4.7/comtypes/test/test_server.py +0 -348
  87. comtypes-1.4.7/comtypes/test/test_stream.py +0 -53
  88. comtypes-1.4.7/pyproject.toml +0 -3
  89. {comtypes-1.4.7 → comtypes-1.4.9}/LICENSE.txt +0 -0
  90. {comtypes-1.4.7 → comtypes-1.4.9}/MANIFEST.in +0 -0
  91. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_post_coinit/bstr.py +0 -0
  92. /comtypes-1.4.7/comtypes/_py_instance_method.py → /comtypes-1.4.9/comtypes/_post_coinit/instancemethod.py +0 -0
  93. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/_tlib_version_checker.py +0 -0
  94. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/clear_cache.py +0 -0
  95. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/client/dynamic.py +0 -0
  96. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/connectionpoints.py +0 -0
  97. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/hresult.py +0 -0
  98. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/logutil.py +0 -0
  99. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/messageloop.py +0 -0
  100. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/patcher.py +0 -0
  101. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/automation.py +0 -0
  102. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/server/connectionpoints.py +0 -0
  103. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/stream.py +0 -0
  104. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.idl +0 -0
  105. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestComServer.tlb +0 -0
  106. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.idl +0 -0
  107. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/TestDispServer.tlb +0 -0
  108. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.idl +0 -0
  109. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mylib.tlb +0 -0
  110. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/mytypelib.idl +0 -0
  111. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/runtests.py +0 -0
  112. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/setup.py +0 -0
  113. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_DISPPARAMS.py +0 -0
  114. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_GUID.py +0 -0
  115. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_QueryService.py +0 -0
  116. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_basic.py +0 -0
  117. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client.py +0 -0
  118. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_dynamic.py +0 -0
  119. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_client_regenerate_modules.py +0 -0
  120. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dict.py +0 -0
  121. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_records.py +0 -0
  122. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dispifc_safearrays.py +0 -0
  123. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_dyndispatch.py +0 -0
  124. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_findgendir.py +0 -0
  125. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_getactiveobj.py +0 -0
  126. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_ienum.py +0 -0
  127. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_imfattributes.py +0 -0
  128. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_jscript.js +0 -0
  129. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_monikers.py +0 -0
  130. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_msscript.py +0 -0
  131. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_npsupport.py +0 -0
  132. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_persist.py +0 -0
  133. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_pump_events.py +0 -0
  134. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_recordinfo.py +0 -0
  135. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_sapi.py +0 -0
  136. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_storage.py +0 -0
  137. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_subinterface.py +0 -0
  138. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_typeinfo.py +0 -0
  139. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/test_word.py +0 -0
  140. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/test/urlhist.tlb +0 -0
  141. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/__init__.py +0 -0
  142. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/__init__.py +0 -0
  143. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  144. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes/tools/typedesc_base.py +0 -0
  145. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/dependency_links.txt +0 -0
  146. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/entry_points.txt +0 -0
  147. {comtypes-1.4.7 → comtypes-1.4.9}/comtypes.egg-info/top_level.txt +0 -0
  148. {comtypes-1.4.7 → comtypes-1.4.9}/setup.cfg +0 -0
  149. {comtypes-1.4.7 → comtypes-1.4.9}/setup.py +0 -0
@@ -1,67 +0,0 @@
1
- from comtypes._memberspec import _ComMemberSpec, _DispMemberSpec, _resolve_argspec
2
-
3
-
4
- class helpstring(str):
5
- "Specifies the helpstring for a COM method or property."
6
-
7
-
8
- class defaultvalue(object):
9
- "Specifies the default value for parameters marked optional."
10
-
11
- def __init__(self, value):
12
- self.value = value
13
-
14
-
15
- class dispid(int):
16
- "Specifies the DISPID of a method or property."
17
-
18
-
19
- # XXX STDMETHOD, COMMETHOD, DISPMETHOD, and DISPPROPERTY should return
20
- # instances with more methods or properties, and should not behave as an unpackable.
21
-
22
-
23
- def STDMETHOD(restype, name, argtypes=()) -> _ComMemberSpec:
24
- "Specifies a COM method slot without idlflags"
25
- return _ComMemberSpec(restype, name, argtypes, None, (), None)
26
-
27
-
28
- def DISPMETHOD(idlflags, restype, name, *argspec) -> _DispMemberSpec:
29
- "Specifies a method of a dispinterface"
30
- return _DispMemberSpec("DISPMETHOD", name, tuple(idlflags), restype, argspec)
31
-
32
-
33
- def DISPPROPERTY(idlflags, proptype, name) -> _DispMemberSpec:
34
- "Specifies a property of a dispinterface"
35
- return _DispMemberSpec("DISPPROPERTY", name, tuple(idlflags), proptype, ())
36
-
37
-
38
- # tuple(idlflags) is for the method itself: (dispid, 'readonly')
39
-
40
- # sample generated code:
41
- # DISPPROPERTY([5, 'readonly'], OLE_YSIZE_HIMETRIC, 'Height'),
42
- # DISPMETHOD(
43
- # [6], None, 'Render', ([], c_int, 'hdc'), ([], c_int, 'x'), ([], c_int, 'y')
44
- # )
45
-
46
-
47
- def COMMETHOD(idlflags, restype, methodname, *argspec) -> _ComMemberSpec:
48
- """Specifies a COM method slot with idlflags.
49
-
50
- XXX should explain the sematics of the arguments.
51
- """
52
- # collect all helpstring instances
53
- # We should suppress docstrings when Python is started with -OO
54
- # join them together(does this make sense?) and replace by None if empty.
55
- helptext = "".join(t for t in idlflags if isinstance(t, helpstring)) or None
56
- paramflags, argtypes = _resolve_argspec(argspec)
57
- if "propget" in idlflags:
58
- name = "_get_%s" % methodname
59
- elif "propput" in idlflags:
60
- name = "_set_%s" % methodname
61
- elif "propputref" in idlflags:
62
- name = "_setref_%s" % methodname
63
- else:
64
- name = methodname
65
- return _ComMemberSpec(
66
- restype, name, argtypes, paramflags, tuple(idlflags), helptext
67
- )
@@ -1,70 +0,0 @@
1
- # comtypes._meta helper module
2
- from ctypes import POINTER, c_void_p, cast
3
- import comtypes
4
-
5
- ################################################################
6
- # metaclass for CoClass (in comtypes/__init__.py)
7
-
8
-
9
- def _wrap_coclass(self):
10
- # We are an IUnknown pointer, represented as a c_void_p instance,
11
- # but we really want this interface:
12
- itf = self._com_interfaces_[0]
13
- punk = cast(self, POINTER(itf))
14
- result = punk.QueryInterface(itf)
15
- result.__dict__["__clsid"] = str(self._reg_clsid_)
16
- return result
17
-
18
-
19
- def _coclass_from_param(cls, obj):
20
- if isinstance(obj, (cls._com_interfaces_[0], cls)):
21
- return obj
22
- raise TypeError(obj)
23
-
24
-
25
- #
26
- # The mro() of a POINTER(App) type, where class App is a subclass of CoClass:
27
- #
28
- # POINTER(App)
29
- # App
30
- # CoClass
31
- # c_void_p
32
- # _SimpleCData
33
- # _CData
34
- # object
35
-
36
-
37
- class _coclass_meta(type):
38
- # metaclass for CoClass
39
- #
40
- # When a CoClass subclass is created, create a POINTER(...) type
41
- # for that class, with bases <coclass> and c_void_p. Also, the
42
- # POINTER(...) type gets a __ctypes_from_outparam__ method which
43
- # will QueryInterface for the default interface: the first one on
44
- # the coclass' _com_interfaces_ list.
45
- def __new__(cls, name, bases, namespace):
46
- klass = type.__new__(cls, name, bases, namespace)
47
- if bases == (object,):
48
- return klass
49
- # XXX We should insist that a _reg_clsid_ is present.
50
- if "_reg_clsid_" in namespace:
51
- clsid = namespace["_reg_clsid_"]
52
- comtypes.com_coclass_registry[str(clsid)] = klass
53
- PTR = _coclass_pointer_meta(
54
- "POINTER(%s)" % klass.__name__,
55
- (klass, c_void_p),
56
- {
57
- "__ctypes_from_outparam__": _wrap_coclass,
58
- "from_param": classmethod(_coclass_from_param),
59
- },
60
- )
61
- from ctypes import _pointer_type_cache
62
-
63
- _pointer_type_cache[klass] = PTR
64
-
65
- return klass
66
-
67
-
68
- # will not work if we change the order of the two base classes!
69
- class _coclass_pointer_meta(type(c_void_p), _coclass_meta):
70
- pass
@@ -1,69 +0,0 @@
1
- import comtypes.client, ctypes
2
-
3
- ################################################################
4
- # Interfaces
5
- class IClassFactory(comtypes.IUnknown):
6
- _iid_ = comtypes.GUID("{00000001-0000-0000-C000-000000000046}")
7
- _methods_ = [
8
- comtypes.STDMETHOD(
9
- comtypes.HRESULT,
10
- "CreateInstance",
11
- [
12
- ctypes.POINTER(comtypes.IUnknown),
13
- ctypes.POINTER(comtypes.GUID),
14
- ctypes.POINTER(ctypes.c_void_p),
15
- ],
16
- ),
17
- comtypes.STDMETHOD(comtypes.HRESULT, "LockServer", [ctypes.c_int]),
18
- ]
19
-
20
- def CreateInstance(self, punkouter=None, interface=None, dynamic=False):
21
- if dynamic:
22
- if interface is not None:
23
- raise ValueError("interface and dynamic are mutually exclusive")
24
- realInterface = comtypes.automation.IDispatch
25
- elif interface is None:
26
- realInterface = comtypes.IUnknown
27
- else:
28
- realInterface = interface
29
- obj = ctypes.POINTER(realInterface)()
30
- self.__com_CreateInstance(punkouter, realInterface._iid_, ctypes.byref(obj))
31
- if dynamic:
32
- return comtypes.client.dynamic.Dispatch(obj)
33
- elif interface is None:
34
- # An interface was not specified, so return the best.
35
- return comtypes.client.GetBestInterface(obj)
36
- # An interface was specified and obj is already that interface.
37
- return obj
38
-
39
-
40
- # class IExternalConnection(IUnknown):
41
- # _iid_ = GUID("{00000019-0000-0000-C000-000000000046}")
42
- # _methods_ = [
43
- # STDMETHOD(HRESULT, "AddConnection", [c_ulong, c_ulong]),
44
- # STDMETHOD(HRESULT, "ReleaseConnection", [c_ulong, c_ulong, c_ulong])]
45
-
46
- # The following code is untested:
47
-
48
- ACTIVEOBJECT_STRONG = 0x0
49
- ACTIVEOBJECT_WEAK = 0x1
50
-
51
- oleaut32 = ctypes.oledll.oleaut32
52
-
53
-
54
- def RegisterActiveObject(comobj, weak=True):
55
- punk = comobj._com_pointers_[comtypes.IUnknown._iid_]
56
- clsid = comobj._reg_clsid_
57
- if weak:
58
- flags = ACTIVEOBJECT_WEAK
59
- else:
60
- flags = ACTIVEOBJECT_STRONG
61
- handle = ctypes.c_ulong()
62
- oleaut32.RegisterActiveObject(
63
- punk, ctypes.byref(clsid), flags, ctypes.byref(handle)
64
- )
65
- return handle.value
66
-
67
-
68
- def RevokeActiveObject(handle):
69
- oleaut32.RevokeActiveObject(handle, None)
@@ -1,75 +0,0 @@
1
- class GetoptError(Exception):
2
- pass
3
-
4
-
5
- def w_getopt(args, options):
6
- """A getopt for Windows.
7
-
8
- Options may start with either '-' or '/', the option names may
9
- have more than one letter (/tlb or -RegServer), and option names
10
- are case insensitive.
11
-
12
- Returns two elements, just as getopt.getopt. The first is a list
13
- of (option, value) pairs in the same way getopt.getopt does, but
14
- there is no '-' or '/' prefix to the option name, and the option
15
- name is always lower case. The second is the list of arguments
16
- which do not belong to an option.
17
-
18
- Different from getopt.getopt, a single argument not belonging to an option
19
- does not terminate parsing.
20
- """
21
- opts = []
22
- arguments = []
23
- while args:
24
- if args[0][:1] in "/-":
25
- arg = args[0][1:] # strip the '-' or '/'
26
- arg = arg.lower()
27
-
28
- if arg + ":" in options:
29
- try:
30
- opts.append((arg, args[1]))
31
- except IndexError:
32
- raise GetoptError("option '%s' requires an argument" % args[0])
33
- args = args[1:]
34
- elif arg in options:
35
- opts.append((arg, ""))
36
- else:
37
- raise GetoptError("invalid option '%s'" % args[0])
38
- args = args[1:]
39
- else:
40
- arguments.append(args[0])
41
- args = args[1:]
42
-
43
- return opts, arguments
44
-
45
-
46
- if __debug__:
47
- if __name__ == "__main__":
48
- import unittest
49
-
50
- class TestCase(unittest.TestCase):
51
- def test_1(self):
52
- args = "-embedding spam /RegServer foo /UnregSERVER blabla".split()
53
- opts, args = w_getopt(args, "regserver unregserver embedding".split())
54
- self.assertEqual(
55
- opts, [("embedding", ""), ("regserver", ""), ("unregserver", "")]
56
- )
57
- self.assertEqual(args, ["spam", "foo", "blabla"])
58
-
59
- def test_2(self):
60
- args = "/TLB Hello.Tlb HELLO.idl".split()
61
- opts, args = w_getopt(args, ["tlb:"])
62
- self.assertEqual(opts, [("tlb", "Hello.Tlb")])
63
- self.assertEqual(args, ["HELLO.idl"])
64
-
65
- def test_3(self):
66
- # Invalid option
67
- self.assertRaises(
68
- GetoptError, w_getopt, "/TLIB hello.tlb hello.idl".split(), ["tlb:"]
69
- )
70
-
71
- def test_4(self):
72
- # Missing argument
73
- self.assertRaises(GetoptError, w_getopt, "/TLB".split(), ["tlb:"])
74
-
75
- unittest.main()
@@ -1,239 +0,0 @@
1
- import sys
2
- import unittest
3
-
4
- import comtypes.test.TestComServer
5
- from comtypes.client import CreateObject
6
- from comtypes.server.register import register # , unregister
7
- from comtypes.test import is_resource_enabled
8
- from comtypes.test.find_memleak import find_memleak
9
-
10
-
11
- def setUpModule():
12
- raise unittest.SkipTest(
13
- "This test requires the tests to be run as admin since it tries to "
14
- "register the test COM server. Is this a good idea?"
15
- )
16
-
17
- # If this test is ever NOT skipped, then this line needs to run. Keeping it here for posterity.
18
- register(comtypes.test.TestComServer.TestComServer)
19
-
20
-
21
- class TestInproc(unittest.TestCase):
22
- def create_object(self):
23
- return CreateObject(
24
- "TestComServerLib.TestComServer", clsctx=comtypes.CLSCTX_INPROC_SERVER
25
- )
26
-
27
- def _find_memleak(self, func):
28
- bytes = find_memleak(func)
29
- self.assertFalse(bytes, "Leaks %d bytes" % bytes)
30
-
31
- def test_mixedinout(self):
32
- o = self.create_object()
33
- self.assertEqual(o.MixedInOut(2, 4), (3, 5))
34
-
35
- def test_getname(self):
36
- from ctypes import pointer
37
- from comtypes import BSTR
38
-
39
- # This tests a tricky bug, introduced with this patch:
40
- # http://www.python.org/sf/1643874
41
- #
42
- # Returning a BSTR as an [out] parameter from a server
43
- # implementation must transfer the ownership to the caller.
44
- # When this is not done, the BSTR instance is SysFreeString'd
45
- # too early, and the memory is reused.
46
- obj = self.create_object()
47
- pb = pointer(BSTR())
48
- # Get the BSTR from the server:
49
- obj._ITestComServer__com__get_name(pb)
50
- # Retrieve the value, but keep the pointer to the BSTR alive:
51
- name = pb[0]
52
- # Create sme BSTR's to reuse the memory in case it has been freed:
53
- for i in range(10):
54
- BSTR("f" * len(name))
55
- # Make sure the pointer is still valid:
56
- self.assertEqual(pb[0], name)
57
-
58
- if is_resource_enabled("memleaks"):
59
-
60
- def test_get_id(self):
61
- obj = self.create_object()
62
- self._find_memleak(lambda: obj.id)
63
-
64
- def test_get_name(self):
65
- obj = self.create_object()
66
- self._find_memleak(lambda: obj.name)
67
-
68
- def test_set_name(self):
69
- obj = self.create_object()
70
-
71
- def func():
72
- obj.name = "abcde"
73
-
74
- self._find_memleak(func)
75
-
76
- def test_SetName(self):
77
- obj = self.create_object()
78
-
79
- def func():
80
- obj.SetName("abcde")
81
-
82
- self._find_memleak(func)
83
-
84
- def test_eval(self):
85
- obj = self.create_object()
86
-
87
- def func():
88
- return obj.eval("(1, 2, 3)")
89
-
90
- self.assertEqual(func(), (1, 2, 3))
91
- self._find_memleak(func)
92
-
93
- def test_get_typeinfo(self):
94
- obj = self.create_object()
95
-
96
- def func():
97
- obj.GetTypeInfo(0)
98
- obj.GetTypeInfoCount()
99
- obj.QueryInterface(comtypes.IUnknown)
100
-
101
- self._find_memleak(func)
102
-
103
-
104
- if is_resource_enabled("ui"):
105
-
106
- class TestLocalServer(TestInproc):
107
- def create_object(self):
108
- return CreateObject(
109
- "TestComServerLib.TestComServer", clsctx=comtypes.CLSCTX_LOCAL_SERVER
110
- )
111
-
112
-
113
- try:
114
- from win32com.client import Dispatch
115
- except ImportError:
116
- pass
117
- else:
118
-
119
- class TestInproc_win32com(TestInproc):
120
- def create_object(self):
121
- return Dispatch("TestComServerLib.TestComServer")
122
-
123
- # These tests make no sense with win32com, override to disable them:
124
- def test_get_typeinfo(self):
125
- pass
126
-
127
- def test_getname(self):
128
- pass
129
-
130
- def test_mixedinout(self):
131
- # Not sure about this; it raise 'Invalid Number of parameters'
132
- # Is mixed [in], [out] args not compatible with IDispatch???
133
- pass
134
-
135
- if is_resource_enabled("ui"):
136
-
137
- class TestLocalServer_win32com(TestInproc_win32com):
138
- def create_object(self):
139
- return Dispatch(
140
- "TestComServerLib.TestComServer",
141
- clsctx=comtypes.CLSCTX_LOCAL_SERVER,
142
- )
143
-
144
-
145
- import doctest
146
- import comtypes.test.test_comserver
147
-
148
-
149
- class TestCase(unittest.TestCase):
150
- def test(self):
151
- doctest.testmod(comtypes.test.test_comserver, optionflags=doctest.ELLIPSIS)
152
-
153
- # The following functions are never called, they only contain doctests:
154
-
155
- if sys.version_info >= (3, 0):
156
-
157
- def ShowEvents(self):
158
- """
159
- >>> from comtypes.client import CreateObject, ShowEvents
160
- >>>
161
- >>> o = CreateObject("TestComServerLib.TestComServer")
162
- >>> con = ShowEvents(o)
163
- # event found: ITestComServerEvents_EvalStarted
164
- # event found: ITestComServerEvents_EvalCompleted
165
- >>> result = o.eval("10. / 4")
166
- Event ITestComServerEvents_EvalStarted(None, '10. / 4')
167
- Event ITestComServerEvents_EvalCompleted(None, '10. / 4', VARIANT(vt=0x5, 2.5))
168
- >>> result
169
- 2.5
170
- >>>
171
- """
172
-
173
- else:
174
-
175
- def ShowEvents(self):
176
- """
177
- >>> from comtypes.client import CreateObject, ShowEvents
178
- >>>
179
- >>> o = CreateObject("TestComServerLib.TestComServer")
180
- >>> con = ShowEvents(o)
181
- # event found: ITestComServerEvents_EvalStarted
182
- # event found: ITestComServerEvents_EvalCompleted
183
- >>> result = o.eval("10. / 4")
184
- Event ITestComServerEvents_EvalStarted(None, u'10. / 4')
185
- Event ITestComServerEvents_EvalCompleted(None, u'10. / 4', VARIANT(vt=0x5, 2.5))
186
- >>> result
187
- 2.5
188
- >>>
189
- """
190
-
191
- # The following test, if enabled, works but the testsuit
192
- # crashes elsewhere. Is there s problem with SAFEARRAYs?
193
-
194
- if is_resource_enabled("CRASHES"):
195
-
196
- def Fails(self):
197
- """
198
- >>> from comtypes.client import CreateObject, ShowEvents
199
- >>>
200
- >>> o = CreateObject("TestComServerLib.TestComServer")
201
- >>> con = ShowEvents(o)
202
- # event found: ITestComServerEvents_EvalStarted
203
- # event found: ITestComServerEvents_EvalCompleted
204
- >>> result = o.eval("['32'] * 2")
205
- Event ITestComServerEvents_EvalStarted(None, u"['32'] * 2")
206
- Event ITestComServerEvents_EvalCompleted(None, u"['32'] * 2", VARIANT(vt=0x200c, (u'32', u'32')))
207
- >>> result
208
- (u'32', u'32')
209
- >>>
210
- """
211
-
212
- def GetEvents(self):
213
- """
214
- >>> from comtypes.client import CreateObject, GetEvents
215
- >>>
216
- >>> o = CreateObject("TestComServerLib.TestComServer")
217
- >>> class EventHandler(object):
218
- ... def EvalStarted(self, this, what):
219
- ... print("EvalStarted: %s" % what)
220
- ... return 0
221
- ... def EvalCompleted(self, this, what, result):
222
- ... print("EvalCompleted: %s = %s" % (what, result.value))
223
- ... return 0
224
- ...
225
- >>>
226
- >>> con = GetEvents(o, EventHandler())
227
- >>> o.eval("2 + 3")
228
- EvalStarted: 2 + 3
229
- EvalCompleted: 2 + 3 = 5
230
- 5
231
- >>> del con
232
- >>> o.eval("3 + 2")
233
- 5
234
- >>>
235
- """
236
-
237
-
238
- if __name__ == "__main__":
239
- unittest.main()
@@ -1,138 +0,0 @@
1
- import unittest
2
-
3
- import comtypes.test.TestDispServer
4
- from comtypes.server.register import register # , unregister
5
- from comtypes.test import is_resource_enabled
6
-
7
-
8
- def setUpModule():
9
- raise unittest.SkipTest(
10
- "This test requires the tests to be run as admin since it tries to "
11
- "register the test COM server. Is this a good idea?"
12
- )
13
-
14
- # If this test is ever NOT skipped, then this line needs to run. Keeping it here for posterity.
15
- register(comtypes.test.TestDispServer.TestDispServer)
16
-
17
-
18
- class Test(unittest.TestCase):
19
-
20
- if is_resource_enabled("pythoncom"):
21
-
22
- def test_win32com(self):
23
- # EnsureDispatch is case-sensitive
24
- from win32com.client.gencache import EnsureDispatch
25
-
26
- d = EnsureDispatch("TestDispServerLib.TestDispServer")
27
-
28
- self.assertEqual(d.eval("3.14"), 3.14)
29
- self.assertEqual(d.eval("1 + 2"), 3)
30
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
31
-
32
- self.assertEqual(d.eval2("3.14"), 3.14)
33
- self.assertEqual(d.eval2("1 + 2"), 3)
34
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
35
-
36
- d.eval(
37
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
38
- )
39
-
40
- server_id = d.eval("id(self)")
41
- self.assertEqual(d.id, server_id)
42
-
43
- self.assertEqual(d.name, "spam, spam, spam")
44
-
45
- d.SetName("foo bar")
46
- self.assertEqual(d.name, "foo bar")
47
-
48
- d.name = "blah"
49
- self.assertEqual(d.name, "blah")
50
-
51
- def test_win32com_dyndispatch(self):
52
- # dynamic Dispatch is case-IN-sensitive
53
- from win32com.client.dynamic import Dispatch
54
-
55
- d = Dispatch("TestDispServerLib.TestDispServer")
56
-
57
- self.assertEqual(d.eval("3.14"), 3.14)
58
- self.assertEqual(d.eval("1 + 2"), 3)
59
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
60
-
61
- self.assertEqual(d.eval2("3.14"), 3.14)
62
- self.assertEqual(d.eval2("1 + 2"), 3)
63
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
64
-
65
- d.eval(
66
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
67
- )
68
-
69
- self.assertEqual(d.EVAL("3.14"), 3.14)
70
- self.assertEqual(d.EVAL("1 + 2"), 3)
71
- self.assertEqual(d.EVAL("[1 + 2, 'foo', None]"), (3, "foo", None))
72
-
73
- self.assertEqual(d.EVAL2("3.14"), 3.14)
74
- self.assertEqual(d.EVAL2("1 + 2"), 3)
75
- self.assertEqual(d.EVAL2("[1 + 2, 'foo', None]"), (3, "foo", None))
76
-
77
- server_id = d.eval("id(self)")
78
- self.assertEqual(d.id, server_id)
79
- self.assertEqual(d.ID, server_id)
80
-
81
- self.assertEqual(d.Name, "spam, spam, spam")
82
- self.assertEqual(d.nAME, "spam, spam, spam")
83
-
84
- d.SetName("foo bar")
85
- self.assertEqual(d.Name, "foo bar")
86
-
87
- # fails. Why?
88
- # d.name = "blah"
89
- # self.assertEqual(d.Name, "blah")
90
-
91
- def test_comtypes(self):
92
- from comtypes.client import CreateObject
93
-
94
- d = CreateObject("TestDispServerLib.TestDispServer")
95
-
96
- self.assertEqual(d.eval("3.14"), 3.14)
97
- self.assertEqual(d.eval("1 + 2"), 3)
98
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
99
-
100
- self.assertEqual(d.eval2("3.14"), 3.14)
101
- self.assertEqual(d.eval2("1 + 2"), 3)
102
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
103
-
104
- d.eval(
105
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
106
- )
107
-
108
- self.assertEqual(d.EVAL("3.14"), 3.14)
109
- self.assertEqual(d.EVAL("1 + 2"), 3)
110
- self.assertEqual(d.EVAL("[1 + 2, 'foo', None]"), (3, "foo", None))
111
-
112
- self.assertEqual(d.EVAL2("3.14"), 3.14)
113
- self.assertEqual(d.EVAL2("1 + 2"), 3)
114
- self.assertEqual(d.EVAL2("[1 + 2, 'foo', None]"), (3, "foo", None))
115
-
116
- server_id = d.eval("id(self)")
117
- self.assertEqual(d.id, server_id)
118
- self.assertEqual(d.ID, server_id)
119
-
120
- self.assertEqual(d.Name, "spam, spam, spam")
121
- self.assertEqual(d.nAME, "spam, spam, spam")
122
-
123
- d.SetName("foo bar")
124
- self.assertEqual(d.Name, "foo bar")
125
-
126
- d.name = "blah"
127
- self.assertEqual(d.Name, "blah")
128
-
129
- def test_withjscript(self):
130
- import os
131
-
132
- jscript = os.path.join(os.path.dirname(__file__), "test_jscript.js")
133
- errcode = os.system("cscript -nologo %s" % jscript)
134
- self.assertEqual(errcode, 0)
135
-
136
-
137
- if __name__ == "__main__":
138
- unittest.main()
@@ -1,40 +0,0 @@
1
- # There are also propputref tests in test_sapi.py!
2
- import unittest
3
- from comtypes.client import CreateObject
4
- from comtypes.automation import VARIANT
5
-
6
-
7
- class Test(unittest.TestCase):
8
- @unittest.skip(
9
- "Fails on creating `TestComServerLib.TestComServer`. Figure out why."
10
- )
11
- def test(self, dynamic=False):
12
- d = CreateObject("Scripting.Dictionary", dynamic=dynamic)
13
- s = CreateObject("TestComServerLib.TestComServer", dynamic=dynamic)
14
- s.name = "the value"
15
-
16
- # This calls propputref, since we assign an Object
17
- d.Item["object"] = s
18
- # This calls propput, since we assing a Value
19
- d.Item["value"] = s.name
20
-
21
- self.assertEqual(d.Item["object"], s)
22
- self.assertEqual(d.Item["object"].name, "the value")
23
- self.assertEqual(d.Item["value"], "the value")
24
-
25
- # Changing the default property of the object
26
- s.name = "foo bar"
27
- self.assertEqual(d.Item["object"], s)
28
- self.assertEqual(d.Item["object"].name, "foo bar")
29
- self.assertEqual(d.Item["value"], "the value")
30
-
31
- # This also calls propputref since we assign an Object
32
- d.Item["var"] = VARIANT(s)
33
- self.assertEqual(d.Item["var"], s)
34
-
35
- def test_dispatch(self):
36
- return self.test(dynamic=True)
37
-
38
-
39
- if __name__ == "__main__":
40
- unittest.main()