home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import string
- import pythoncom
- from win32com.server import util, policy
- from win32com.server.exception import COMException
- import winerror
- import types
- import pywintypes
- from pythoncom import DISPATCH_METHOD, DISPATCH_PROPERTYGET
- from winerror import S_OK
- UnicodeType = pywintypes.UnicodeType
- StringType = types.StringType
-
- class DictionaryPolicy(policy.BasicWrapPolicy):
- _com_interfaces_ = []
- _name_to_dispid_ = {
- 'item': pythoncom.DISPID_VALUE,
- '_newenum': pythoncom.DISPID_NEWENUM,
- 'count': 1 }
- _reg_desc_ = 'Python Dictionary'
- _reg_clsid_ = '{39b61048-c755-11d0-86fa-00c04fc2e03e}'
- _reg_progid_ = 'Python.Dictionary'
- _reg_verprogid_ = 'Python.Dictionary.1'
- _reg_policy_spec_ = 'win32com.servers.dictionary.DictionaryPolicy'
-
- def _CreateInstance_(self, clsid, reqIID):
- self._wrap_({ })
- return pythoncom.WrapObject(self, reqIID)
-
-
- def _wrap_(self, ob):
- self._obj_ = ob
-
-
- def _invokeex_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider):
- if dispid == 0:
- l = len(args)
- if l < 1:
- raise COMException(desc = 'not enough parameters', scode = winerror.DISP_E_BADPARAMCOUNT)
- l < 1
- key = args[0]
- if type(key) == UnicodeType:
- pass
- elif type(key) == StringType:
- key = pywintypes.Unicode(key)
- else:
- raise COMException(desc = 'Key must be a string', scode = winerror.DISP_E_TYPEMISMATCH)
- key = (type(key) == UnicodeType).lower()
- if wFlags & (DISPATCH_METHOD | DISPATCH_PROPERTYGET):
- if l > 1:
- raise COMException(scode = winerror.DISP_E_BADPARAMCOUNT)
- l > 1
-
- try:
- return self._obj_[key]
- except KeyError:
- return None
-
-
- None<EXCEPTION MATCH>KeyError
- if l != 2:
- raise COMException(scode = winerror.DISP_E_BADPARAMCOUNT)
- l != 2
- if args[1] is None:
-
- try:
- del self._obj_[key]
- except KeyError:
- pass
- except:
- None<EXCEPTION MATCH>KeyError
-
-
- None<EXCEPTION MATCH>KeyError
- self._obj_[key] = args[1]
- return S_OK
- if dispid == 1:
- if not wFlags & DISPATCH_PROPERTYGET:
- raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND)
- wFlags & DISPATCH_PROPERTYGET
- if len(args) != 0:
- raise COMException(scode = winerror.DISP_E_BADPARAMCOUNT)
- len(args) != 0
- return len(self._obj_)
- if dispid == pythoncom.DISPID_NEWENUM:
- return util.NewEnum(self._obj_.keys())
- raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND)
-
-
- def _getidsofnames_(self, names, lcid):
- name = string.lower(names[0])
-
- try:
- return (self._name_to_dispid_[name],)
- except KeyError:
- raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc = 'Member not found')
-
-
-
-
- def Register():
- UseCommandLine = UseCommandLine
- import win32com.server.register
- return UseCommandLine(DictionaryPolicy)
-
- if __name__ == '__main__':
- Register()
-
-