ó
¢¿[Mc           @   s¾   d  Z  d d l Z d d l m Z m Z d d l m Z d d l Z d d l Z d d l	 Z	 d d l m
 Z
 m Z d d l m Z d e j f d „  ƒ  YZ d	 „  Z e d
 k rº e ƒ  n  d S(   s<  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
iÿÿÿÿN(   t   utilt   policy(   t   COMException(   t   DISPATCH_METHODt   DISPATCH_PROPERTYGET(   t   S_OKt   DictionaryPolicyc           B   sq   e  Z g  Z i e j d  6e j d 6d d 6Z d Z d Z d Z	 d Z
 d Z d	 „  Z d
 „  Z d „  Z d „  Z RS(   t   itemt   _newenumi   t   counts   Python Dictionarys&   {39b61048-c755-11d0-86fa-00c04fc2e03e}s   Python.Dictionarys   Python.Dictionary.1s,   win32com.servers.dictionary.DictionaryPolicyc         C   s   |  j  i  ƒ t j |  | ƒ S(   N(   t   _wrap_t	   pythoncomt
   WrapObject(   t   selft   clsidt   reqIID(    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyt   _CreateInstance_>   s    c         C   s   | |  _  d  S(   N(   t   _obj_(   R   t   ob(    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyR
   B   s    c   	      C   sã  | d k rIt  | ƒ } | d k  r? t d d d t j ƒ ‚ n  | d } t | ƒ t t g k r| t d d d t j ƒ ‚ n  | j ƒ  } | t	 t
 B@rÞ | d k r· t d t j ƒ ‚ n  y |  j | SWqÞ t k
 rÚ d  SXn  | d k rÿ t d t j ƒ ‚ n  | d d  k r4y |  j | =WqEt k
 r0qEXn | d |  j | <t S| d k r¨| t
 @stt d t j ƒ ‚ n  t  | ƒ d k r›t d t j ƒ ‚ n  t  |  j ƒ S| t j k rÍt j |  j j ƒ  ƒ St d t j ƒ ‚ d  S(   Ni    i   t   descs   not enough parameterst   scodes   Key must be a stringi   (   t   lenR   t   winerrort   DISP_E_BADPARAMCOUNTt   typet   strt   unicodet   DISP_E_TYPEMISMATCHt   lowerR   R   R   t   KeyErrort   NoneR   t   DISP_E_MEMBERNOTFOUNDR   t   DISPID_NEWENUMR    t   NewEnumt   keys(	   R   t   dispidt   lcidt   wFlagst   argst   kwargst   serviceProvidert   lt   key(    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyt
   _invokeex_E   sB    

c         C   sR   | d j  ƒ  } y |  j | f SWn) t k
 rM t d t j d d ƒ ‚ n Xd  S(   Ni    R   R   s   Member not found(   R   t   _name_to_dispid_R   R   R   R   (   R   t   namesR$   t   name(    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyt   _getidsofnames_r   s    (   t   __name__t
   __module__t   _com_interfaces_R   t   DISPID_VALUER    R,   t
   _reg_desc_t   _reg_clsid_t   _reg_progid_t   _reg_verprogid_t   _reg_policy_spec_R   R
   R+   R/   (    (    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyR   ,   s   


			-c          C   s   d d l  m }  |  t ƒ S(   Niÿÿÿÿ(   t   UseCommandLine(   t   win32com.server.registerR9   R   (   R9   (    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyt   Register}   s    t   __main__(   t   __doc__R   t   win32com.serverR    R   t   win32com.server.exceptionR   R   t   typest
   pywintypesR   R   R   t   BasicWrapPolicyR   R;   R0   (    (    (    s>   K:\RCS\Python\Lib\site-packages\win32com\servers\dictionary.pyt   <module>    s   Q	