Skip to content

Commit

Permalink
adsi: avoid usage from star import and avoid global reassignement ove…
Browse files Browse the repository at this point in the history
…rrides (#2186)
  • Loading branch information
Avasam authored Feb 27, 2024
1 parent 1db3a90 commit bd65ce8
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions com/win32comext/adsi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# interface, as well as via IDispatch.
import pythoncom

from .adsi import * # nopycln: import # win32comext/adsi/adsi.pyd
from .adsi import * # nopycln: import # Re-export everything from win32comext/adsi/adsi.pyd

LCID = 0

Expand All @@ -51,8 +51,8 @@ def _get_good_ret(
class ADSIEnumerator:
def __init__(self, ob):
# Query the object for the container interface.
self._cont_ = ob.QueryInterface(IID_IADsContainer)
self._oleobj_ = ADsBuildEnumerator(self._cont_) # a PyIADsEnumVARIANT
self._cont_ = ob.QueryInterface(adsi.IID_IADsContainer)
self._oleobj_ = adsi.ADsBuildEnumerator(self._cont_) # a PyIADsEnumVARIANT
self.index = -1

def __getitem__(self, index):
Expand All @@ -68,12 +68,12 @@ def __GetIndex(self, index):
# Index requested out of sequence.
raise ValueError("You must index this object sequentially")
self.index = index
result = ADsEnumerateNext(self._oleobj_, 1)
result = adsi.ADsEnumerateNext(self._oleobj_, 1)
if len(result):
return _get_good_ret(result[0])
# Failed - reset for next time around.
self.index = -1
self._oleobj_ = ADsBuildEnumerator(self._cont_) # a PyIADsEnumVARIANT
self._oleobj_ = adsi.ADsBuildEnumerator(self._cont_) # a PyIADsEnumVARIANT
raise IndexError("list index out of range")


Expand Down Expand Up @@ -105,18 +105,12 @@ def QueryInterface(self, iid):
return _get_good_ret(ret)


# We override the global methods to do the right thing.
_ADsGetObject = ADsGetObject # The one in the .pyd


# We override the adsi.pyd methods to do the right thing.
def ADsGetObject(path, iid=pythoncom.IID_IDispatch):
ret = _ADsGetObject(path, iid)
ret = adsi.ADsGetObject(path, iid)
return _get_good_ret(ret)


_ADsOpenObject = ADsOpenObject


def ADsOpenObject(path, username, password, reserved=0, iid=pythoncom.IID_IDispatch):
ret = _ADsOpenObject(path, username, password, reserved, iid)
ret = adsi.ADsOpenObject(path, username, password, reserved, iid)
return _get_good_ret(ret)

0 comments on commit bd65ce8

Please sign in to comment.