Skip to content

Commit 2cd4d20

Browse files
committed
adjust import part and references (enthought#439)
(cherry picked from commit 0fecfea)
1 parent c83ceb0 commit 2cd4d20

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

comtypes/client/dynamic.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import ctypes
2-
import comtypes.automation
3-
import comtypes.typeinfo
4-
import comtypes.client
5-
import comtypes.client.lazybind
62

7-
from comtypes import COMError, IUnknown, _is_object
8-
import comtypes.hresult as hres
3+
from comtypes import automation
4+
from comtypes.client import lazybind
5+
from comtypes import COMError, hresult as hres, _is_object
96

107
# These errors generally mean the property or method exists,
118
# but can't be used in this context - eg, property instead of a method, etc.
@@ -24,12 +21,12 @@ def Dispatch(obj):
2421
# via fully dynamic dispatch
2522
if isinstance(obj, _Dispatch):
2623
return obj
27-
if isinstance(obj, ctypes.POINTER(comtypes.automation.IDispatch)):
24+
if isinstance(obj, ctypes.POINTER(automation.IDispatch)):
2825
try:
2926
tinfo = obj.GetTypeInfo(0)
30-
except (comtypes.COMError, WindowsError):
27+
except (COMError, WindowsError):
3128
return _Dispatch(obj)
32-
return comtypes.client.lazybind.Dispatch(obj, tinfo)
29+
return lazybind.Dispatch(obj, tinfo)
3330
return obj
3431

3532

@@ -45,17 +42,17 @@ def __call__(self, *args):
4542

4643
def __getitem__(self, *args):
4744
return self._obj._comobj.Invoke(
48-
self._id, *args, _invkind=comtypes.automation.DISPATCH_PROPERTYGET
45+
self._id, *args, _invkind=automation.DISPATCH_PROPERTYGET
4946
)
5047

5148
def __setitem__(self, *args):
5249
if _is_object(args[-1]):
5350
self._obj._comobj.Invoke(
54-
self._id, *args, _invkind=comtypes.automation.DISPATCH_PROPERTYPUTREF
51+
self._id, *args, _invkind=automation.DISPATCH_PROPERTYPUTREF
5552
)
5653
else:
5754
self._obj._comobj.Invoke(
58-
self._id, *args, _invkind=comtypes.automation.DISPATCH_PROPERTYPUT
55+
self._id, *args, _invkind=automation.DISPATCH_PROPERTYPUT
5956
)
6057

6158

@@ -70,7 +67,7 @@ def __init__(self, comobj):
7067

7168
def __enum(self):
7269
e = self._comobj.Invoke(-4) # DISPID_NEWENUM
73-
return e.QueryInterface(comtypes.automation.IEnumVARIANT)
70+
return e.QueryInterface(automation.IEnumVARIANT)
7471

7572
def __hash__(self):
7673
return hash(self._comobj)
@@ -118,7 +115,7 @@ def __getattr__(self, name):
118115
self.__dict__[name] = result
119116
return result
120117

121-
flags = comtypes.automation.DISPATCH_PROPERTYGET
118+
flags = automation.DISPATCH_PROPERTYGET
122119
try:
123120
result = self._comobj.Invoke(dispid, _invkind=flags)
124121
except COMError as err:
@@ -149,8 +146,13 @@ def __iter__(self):
149146
return _Collection(self.__enum())
150147

151148
# def __setitem__(self, index, value):
152-
# self._comobj.Invoke(-3, index, value,
153-
# _invkind=comtypes.automation.DISPATCH_PROPERTYPUT|comtypes.automation.DISPATCH_PROPERTYPUTREF)
149+
# self._comobj.Invoke(
150+
# -3,
151+
# index,
152+
# value,
153+
# _invkind=automation.DISPATCH_PROPERTYPUT
154+
# | automation.DISPATCH_PROPERTYPUTREF,
155+
# )
154156

155157

156158
class _Collection(object):

0 commit comments

Comments
 (0)