home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import pythoncom
- import policy
- import winerror
- from exception import COMException
-
- def wrap(ob, iid = None, usePolicy = None, useDispatcher = None):
- if usePolicy is None:
- usePolicy = policy.DefaultPolicy
-
- if useDispatcher == 1:
- import win32com.server.dispatcher as win32com
- useDispatcher = win32com.server.dispatcher.DefaultDebugDispatcher
-
- if useDispatcher is None or useDispatcher == 0:
- ob = usePolicy(ob)
- else:
- ob = useDispatcher(usePolicy, ob)
- ob = pythoncom.WrapObject(ob)
- if iid is not None:
- ob = ob.QueryInterface(iid)
-
- return ob
-
-
- def unwrap(ob):
- ob = pythoncom.UnwrapObject(ob)
- if hasattr(ob, 'policy'):
- ob = ob.policy
-
- return ob._obj_
-
-
- class ListEnumerator:
- _public_methods_ = [
- 'Next',
- 'Skip',
- 'Reset',
- 'Clone']
-
- def __init__(self, data, index = 0, iid = pythoncom.IID_IEnumVARIANT):
- self._list_ = data
- self.index = index
- self._iid_ = iid
-
-
- def _query_interface_(self, iid):
- if iid == self._iid_:
- return 1
-
-
- def Next(self, count):
- result = self._list_[self.index:self.index + count]
- self.Skip(count)
- return result
-
-
- def Skip(self, count):
- end = self.index + count
- if end > len(self._list_):
- end = len(self._list_)
-
- self.index = end
-
-
- def Reset(self):
- self.index = 0
-
-
- def Clone(self):
- return self._wrap(self.__class__(self._list_, self.index))
-
-
- def _wrap(self, ob):
- return wrap(ob)
-
-
-
- class ListEnumeratorGateway(ListEnumerator):
-
- def Next(self, count):
- result = self._list_[self.index:self.index + count]
- self.Skip(count)
- return map(self._wrap, result)
-
-
-
- def NewEnum(seq, cls = ListEnumerator, iid = pythoncom.IID_IEnumVARIANT, usePolicy = None, useDispatcher = None):
- ob = cls(seq, iid = iid)
- return wrap(ob, iid, usePolicy = usePolicy, useDispatcher = useDispatcher)
-
-
- class Collection:
- _public_methods_ = [
- 'Item',
- 'Count',
- 'Add',
- 'Remove',
- 'Insert']
-
- def __init__(self, data = None, readOnly = 0):
- if data is None:
- data = []
-
- self.data = data
- if readOnly:
- self._public_methods_ = [
- 'Item',
- 'Count']
-
-
-
- def Item(self, *args):
- if len(args) != 1:
- raise COMException(scode = winerror.DISP_E_BADPARAMCOUNT)
- len(args) != 1
-
- try:
- return self.data[args[0]]
- except IndexError:
- desc = None
- raise COMException(scode = winerror.DISP_E_BADINDEX, desc = str(desc))
-
-
- _value_ = Item
-
- def Count(self):
- return len(self.data)
-
-
- def Add(self, value):
- self.data.append(value)
-
-
- def Remove(self, index):
-
- try:
- del self.data[index]
- except IndexError:
- desc = None
- raise COMException(scode = winerror.DISP_E_BADINDEX, desc = str(desc))
-
-
-
- def Insert(self, index, value):
-
- try:
- index = int(index)
- except (ValueError, TypeError):
- raise COMException(scode = winerror.DISP_E_TYPEMISMATCH)
-
- self.data.insert(index, value)
-
-
- def _NewEnum(self):
- return NewEnum(self.data)
-
-
-
- def NewCollection(seq, cls = Collection):
- return pythoncom.WrapObject(policy.DefaultPolicy(cls(seq)), pythoncom.IID_IDispatch, pythoncom.IID_IDispatch)
-
-
- class FileStream:
- _public_methods_ = [
- 'Read',
- 'Write',
- 'Clone',
- 'CopyTo',
- 'Seek']
- _com_interfaces_ = [
- pythoncom.IID_IStream]
-
- def __init__(self, file):
- self.file = file
-
-
- def Read(self, amount):
- return self.file.read(amount)
-
-
- def Write(self, data):
- self.file.write(data)
- return len(data)
-
-
- def Clone(self):
- return self._wrap(self.__class__(self.file))
-
-
- def CopyTo(self, dest, cb):
- data = self.file.read(cb)
- cbread = len(data)
- dest.Write(data)
- return (cbread, cbread)
-
-
- def Seek(self, offset, origin):
- self.file.seek(offset, origin)
- return self.file.tell()
-
-
- def _wrap(self, ob):
- return wrap(ob)
-
-
-