idZddlZddlZddlZddlmZmZddlmZmZddl m Z ddlm Z Gddej Z d Zed kr edSdS) a=Python.Dictionary COM Server. This module implements a simple COM server that acts much like a Python dictionary or as a standard string-keyed VB Collection. The keys of the dictionary are strings and are case-insensitive. It uses a highly customized policy to fine-tune the behavior exposed to the COM client. The object exposes the following properties: int Count (readonly) VARIANT Item(BSTR key) (propget for Item) Item(BSTR key, VARIANT value) (propput for Item) Note that 'Item' is the default property, so the following forms of VB code are acceptable: set ob = CreateObject("Python.Dictionary") ob("hello") = "there" ob.Item("hi") = ob("HELLO") All keys are defined, returning VT_NULL (None) if a value has not been stored. To delete a key, simply assign VT_NULL to the key. The object responds to the _NewEnum method by returning an enumerator over the dictionary's keys. This allows for the following type of VB code: for each name in ob debug.print(name, ob(name)) next N)DISPATCH_METHODDISPATCH_PROPERTYGET)policyutil) COMException)S_OKc^eZdZgZejejddZdZdZ dZ dZ dZ dZ d Zd Zd Zd S) DictionaryPolicy)item_newenumcountzPython Dictionaryz&{39b61048-c755-11d0-86fa-00c04fc2e03e}zPython.DictionaryzPython.Dictionary.1z,win32com.servers.dictionary.DictionaryPolicycV|itj||SN)_wrap_ pythoncom WrapObject)selfclsidreqIIDs IC:\PYTHON\_runtimes\venv\Lib\site-packages\win32com/servers/dictionary.py_CreateInstance_z!DictionaryPolicy._CreateInstance_=s$ B#D&111c||_dSr)_obj_)robs rrzDictionaryPolicy._wrap_As  rc|dkr!t|}|dkrtdtj|d}t |t stdtj|}|ttzzr:|dkrttj|j |S|dkrttj|d |j |=n #t$rYnwxYw|d|j |<tS|dkre|tzsttjt|dkrttjt|j S|tjkr&t#jt'|j Sttj)Nrr znot enough parameters)descscodezKey must be a string)r)lenrwinerrorDISP_E_BADPARAMCOUNT isinstancestrDISP_E_TYPEMISMATCHlowerrrrgetKeyErrorrDISP_E_MEMBERNOTFOUNDrDISPID_NEWENUMrNewEnumlist) rdispidlcidwFlagsargskwargsserviceProviderlkeys r _invokeex_zDictionaryPolicy._invokeex_Ds Q;;D A1uu"08Uq'Cc3'' "/x7S))++C+??@ +q55&X-JKKKKz~~c***Avv")FGGGGAw 3D#'q' 3K Q;;00 I")GHHHH4yyA~~")FGGGGtz?? " Y- - -<TZ 0 011 1!?@@@@s9D DDc|d} |j|fS#t$rttjdwxYw)NrzMember not found)rr)r'_name_to_dispid_r)rr"r*)rnamesr/names r_getidsofnames_z DictionaryPolicy._getidsofnames_rshQx~~ )$/1 1   4;M  s *&AN)__name__ __module__ __qualname___com_interfaces_r DISPID_VALUEr+r8 _reg_desc_ _reg_clsid_ _reg_progid__reg_verprogid__reg_policy_spec_rrr6r;rrr r +s&,%J:K&L+OF222,A,A,A\     rr c.ddlm}|tS)NrUseCommandLine)win32com.server.registerrIr rHs rRegisterrK~s%777777 >* + ++r__main__)__doc__r pywintypesr"rrwin32com.serverrrwin32com.server.exceptionrrBasicWrapPolicyr rKr<rFrrrRsB;;;;;;;;((((((((222222PPPPPv-PPPf,,,  z HJJJJJr