³ò
àŸÔPc           @   s¡   d  Z  d d k Z d d k Z e i ƒ  h  Z d e d <d e d <d e d <d	 e d
 <d e d <d e d <d e d <d e d <d „  Z d e f d „  ƒ  YZ d S(   s”   
This module provides access to the KeyValues object which is used to
provide full recursive access to Valve's KeyValues C++ class and file format.
iÿÿÿÿNt	   TYPE_NONEi    t   TYPE_STRINGi   t   TYPE_INTi   t
   TYPE_FLOATi   t   TYPE_PTRi   t   TYPE_WSTRINGi   t
   TYPE_COLORi   t   TYPE_NUMTYPESi   c         C   sQ   t  i |  ƒ } | d j	 o- | d j o  t d | ƒ } d | _ | Sn d Sd S(   sR   
    Returns a KeyValues class for a keygroup created with es.keygroupcreate.
    i    t
   existingidN(   t   est   keygroupgetpointert   Nonet	   KeyValuest   _parent_(   t   namet   xt   k(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   getKeyGroup   s    	R   c           B   sê   e  Z d  Z d Z d Z d d d d d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d e f d „  ƒ  YZ d „  Z RS(   s  
    This is a wrapper class for Valve's C++ KeyValues class. It is basically a
    tree-based datastructure where every node has a name and a value.
    See http://developer.valvesoftware.com/wiki/KeyValues_class for more info
    on Valve's KeyValues C++ class.
    i    c         C   sÜ   | d j	 o | |  _ | |  _ n¶ | d j o[ t i ƒ  |  _ | d j	 o |  i | ƒ n | d j	 o t i |  i t | ƒ ƒ qØ nN | |  _ | d j o t i | i ƒ |  _ n t i	 | i t | ƒ ƒ |  _ d S(   s  
        You can create a new KeyValues object by passing in different
        combinations of arguments:
        With only an existingid, KeyValues returns a wrapper around that
        existing id (i.e. C++ pointer). With only a parent, we'll create a
        new randomly named subkey. With a parent and name, we'll find/make a
        subkey of that name. With a name only, we'll create an unparented key
        with that name. With a filename, we'll load the KeyValues tree from
        disk and return it as the parent.
        N(
   R   t   _id_R   R	   t
   keypcreatet   loadt   keypsetnamet   strt   keypcreatesubkeyt   keypfindsubkey(   t   selfR   t   parentR   t   filename(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __init__*   s    	!	c         C   s   t  i |  i | ƒ d S(   s=   
        Loads this KeyValue's contents from a file.
        N(   R	   t   keyploadfromfileR   (   R   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyR   F   s    c         C   s   t  i |  i | ƒ d S(   s=   
        Saves this KeyValue's contents from a file.
        N(   R	   t   keypsavetofileR   (   R   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   saveK   s    c         C   s   |  i  S(   sA   
        Returns the parent KeyValues class to this one.
        (   R   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt	   getParentP   s    c         C   s   | |  _  d S(   s   
        Attached this key in Python to the other KeyValues. Not recommended to
        be used externally to the class.
        N(   R   (   R   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt	   setParentU   s    c         C   sd   t  |  i t ƒ oM |  i d j o0 |  i i d j o t i |  i i |  i ƒ n d |  _ n d S(   sM   
        Detach this KeyValues key from it's parent KeyValues class.
        i    N(   t
   isinstanceR   R   R   R	   t   keypdetachsubkeyR   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   detachParent[   s    #c         C   s.   g  } x! |  D] } | i  | i ƒ  ƒ q W| S(   s6   
        Returns a list of top-level subkeys.
        (   t   appendt   getName(   R   t   keyerst   i(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   keysc   s
     c         C   s8   |  i  d j o$ |  i d  j o t i |  i  ƒ n d  S(   Ni    (   R   R   R   R	   t
   keypdelete(   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __del__k   s     c         C   s   t  i |  i ƒ S(   N(   R	   t   keypgetnameR   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __str__n   s    c         C   s   |  i  S(   N(   R   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __hash__p   s    c         C   s)   t  | ƒ |  i ƒ  j o t Sn t Sd  S(   N(   R   R)   t   Truet   False(   R   t   item(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __contains__r   s    c         C   s0  t  i |  i t | ƒ t ƒ } | d j p | d j o t d | ‚ nä t  i | ƒ } t | d j o t	 d |  d | ƒ Sn­ t | d j p t | d j o t  i
 |  i t | ƒ ƒ Snn t | d j o t  i |  i t | ƒ ƒ Sn@ t | d	 j o t  i |  i t | ƒ ƒ Sn t d
 t | ‚ d S(   sŠ   
        Look up a value by name, a lot like a dictionary. Can return a value
        or a subkey, depending on what is returned.
        i    s    %s not found in keyvalues objectR    R   R   R   R   R   R   s'   KeyValues does not yet support type: %sN(   R	   R   R   R   R0   R   t   KeyErrort   keypgetdatatypet   typesR   t   keypgetstringt
   keypgetintt   keypgetfloatt   NotImplemented(   R   R   R   t   typ(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __getitem__w   s    "c         C   sÖ   t  | t ƒ o@ t i |  i t | ƒ t ƒ } | o t i | | i ƒ qÒ nƒ t  | t ƒ o  t i	 |  i t | ƒ | ƒ nS t  | t
 ƒ o  t i |  i t | ƒ | ƒ n# t i |  i t | ƒ t | ƒ ƒ d S(   s‘   
        Stores a name/value pair in the keygroup. Only ints, floats, strings,
        and KeyValues classes (as subkeys) can be stored.
        N(   R"   R   R	   R   R   R   R/   t   keyprecursivekeycopyt   intt
   keypsetintt   floatt   keypsetfloatt   keypsetstring(   R   R   t   valueR   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __setitem__Ž   s      c         C   sl   t  i |  i t | ƒ t ƒ } | d j p | d j o t d | ‚ n  t d |  d | ƒ } | i ƒ  d S(   s4   
        Delete a subkey from the keygroup.
        i    s    %s not found in keyvalues objectR   R   N(	   R	   R   R   R   R0   R   R3   R   R$   (   R   R   R   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __delitem__ž   s
    c         C   s   t  i |  i ƒ S(   N(   R	   R,   R   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyR&   ¨   s    t    c         C   s   t  i |  i | ƒ S(   N(   R	   R6   R   (   R   t   var(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt	   getStringª   s    c         C   s   t  i |  i | ƒ S(   N(   R	   R7   R   (   R   RF   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   getInt¬   s    c         C   s   t  i |  i | ƒ S(   N(   R	   R8   R   (   R   RF   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   getFloat®   s    t   KeyValuesIterc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   | i  |  _ | |  _ d  S(   N(   R   t	   nextkeyidR   (   R   t
   currentkey(    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyR   ±   s    c         C   s   |  S(   N(    (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   __iter__´   s    c         C   s‡   |  i  |  i i j o t i |  i  ƒ |  _  n t i |  i  ƒ |  _  |  i  d  j p |  i  d j o
 t ‚ n t d |  i  d |  i ƒ S(   Ni    R   R   (	   RK   R   R   R	   t   keypgetfirstsubkeyt   keypgetnextkeyR   t   StopIterationR   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyt   next¶   s     
(   t   __name__t
   __module__R   RM   RQ   (    (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyRJ   °   s   		c         C   s   |  i  |  ƒ S(   N(   RJ   (   R   (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyRM   ¾   s    N(   RR   RS   t   __doc__R   R   R   R   R   R   R    R!   R$   R)   R+   R-   R.   R2   R;   RC   RD   R&   RG   RH   RI   t   objectRJ   RM   (    (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pyR   !   s.   													
			(   RT   R	   t   psycot   fullR5   R   RU   R   (    (    (    sP   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/keyvalues.pys   <module>   s   








	