³ò
àŸÔPc           @   ss  d  d k  Z  d  d k Z d  d k Z e i ƒ  d e f d „  ƒ  YZ e ƒ  Z d „  Z e i i e _ d „  Z	 e i	 i e	 _ d „  Z
 e i
 i e
 _ d „  Z e i i e _ d „  Z e i i e _ d	 „  Z e i i e _ d
 „  Z e  i i d d e ƒ d „  Z e  i i d d e ƒ d „  Z e  i i d d e ƒ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(   iÿÿÿÿNt
   CMDManagerc           B   s™   e  Z d  e f d „  ƒ  YZ d „  Z e d „ Z d „  Z d d d d „ Z	 d „  Z
 d d d d „ Z d „  Z d	 „  Z e d
 „  ƒ Z e d „  ƒ Z RS(   t   CMDArgsc           B   s   e  Z d  Z d „  Z RS(   st   
      Class based on list used to return es.getargv values
      When cast to a string it returns es.getargs
      c         C   s
   t  i ƒ  S(   N(   t   est   getargs(   t   self(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   __str__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR      s   c         C   s+   h  |  _  h  |  _ h  |  _ t ƒ  |  _ d  S(   N(   t   server_commandst   say_commandst   client_commandst   sett   ex_server_commands(   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   __init__   s    			c         C   s½   |  i  | ƒ t | ƒ } | |  i j oV t i d | ƒ p | o$ t i d | ƒ o t d | ‚ n t i | d | ƒ n t | | ƒ |  i | <| |  i j o |  i i	 | ƒ n d S(   s4    Registeres a server command to a callback function t   variablet   commands.   '%s' is in use as a server command or variables   _cmdlib/serverN(
   t   _validateCallbackt   strR   R   t   existst	   NameErrort   regcmdt   CommandR	   t   remove(   R   t   namet   callbackt   descriptiont	   skipcheck(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   registerServerCommand   s    .c         C   s>   t  | ƒ } | |  i j o |  i i | ƒ |  i | =n d S(   s    Unregisteres a server command N(   R   R	   R   t   add(   R   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   unregisterServerCommand-   s    c         C   sß   |  i  | | | d ƒ |  i | ƒ | d j	 o |  i | ƒ n t | ƒ i ƒ  } t i d | ƒ o t d | ‚ n t i | d | ƒ t	 | | ƒ } |  i
 | <| d j	 o* | d j	 o | i | t | ƒ | ƒ n d S(   s\    Registers a say command to the callback function with the option of authorization services t   sayt
   saycommands   '%s' is in use as a say commands   _cmdlib/sayN(   t   _validateAuthCapabilityR   t   NoneR   t   lowerR   R   R   t	   regsaycmdt   PlayerCommandR
   t   setPermissiont   permissionToInteger(   R   R   R   R   t   auth_capabilityt   auth_recommendedlevelt   auth_fail_callbackt   cmd(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   registerSayCommand6   s    $c         C   sA   t  | ƒ i ƒ  } | |  i j o t i | ƒ |  i | =n d S(   s    Unregisters a say command N(   R   R#   R
   R   t   unregsaycmd(   R   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   unregisterSayCommandG   s    c         C   sß   |  i  | | | d ƒ |  i | ƒ | d j	 o |  i | ƒ n t | ƒ i ƒ  } t i d | ƒ o t d | ‚ n t i | d | ƒ t	 | | ƒ } |  i
 | <| d j	 o* | d j	 o | i | t | ƒ | ƒ n d S(   s_    Registers a client command to the callback function with the option of authorization services t   clientt   clientcommands"   '%s' is in use as a client commands   _cmdlib/clientN(   R!   R   R"   R   R#   R   R   R   t   regclientcmdR%   R   R&   R'   (   R   R   R   R   R(   R)   R*   R+   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   registerClientCommandP   s    $c         C   sA   t  | ƒ i ƒ  } | |  i j o t i | ƒ |  i | =n d S(   s    Unregisters a client command N(   R   R#   R   R   t   unregclientcmd(   R   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   unregisterClientCommanda   s    c         C   sH   | | j o7 | | i  |  i d „  t d t i ƒ  ƒ Dƒ ƒ ƒ n d S(   sÆ   
      This function is called when a server, say, or client command is received
      If the command name is present in the list of the same type of commands, the callback function is called
      c         s   s"   x |  ] } t  i | ƒ Vq Wd  S(   N(   R   t   getargv(   t   .0t   x(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pys	   <genexpr>p   s    i   N(   t   executeR   t   xrangeR   t   getargc(   R   t   cmdlistR   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR   j   s    c         C   s.   t  |  ƒ o t |  t ƒ o |  ƒ  n d S(   so   
      If the callback is not a string or callable function we
      call the callback to raise an error
      N(   t   callablet
   isinstanceR   (   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR   r   s    c         C   s™   | d j o | d j	 o t d ‚ no | d j	 o | d j o t d ‚ nH | d j	 o: | d j	 o- t i d ƒ p t d | d |  ‚ q• n d S(   s˜   
      Raises an error if only one auth argument is provided or both arguments
      are provided but there is no available authorization service
      sB   auth_capability is required when auth_recommendedlevel is providedsB   auth_recommendedlevel is required when auth_capability is providedt   auths   Cannot register s3    command '%s' as no authorization service is loadedN(   R"   t
   ValueErrort   servicest   isRegisteredt   KeyError(   R   R(   R)   t   command_type(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR!   {   s    N(   R   R   t   listR   R   t   FalseR   R   R"   R,   R.   R2   R4   R   t   staticmethodR   R!   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR       s   										c          O   s   t  i |  | Ž  d  S(   N(   t   cmd_managerR   (   t   at   kw(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR      s    c          O   s   t  i |  | Ž  d  S(   N(   RG   R   (   RH   RI   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR   ‘   s    c          O   s   t  i |  | Ž  d  S(   N(   RG   R,   (   RH   RI   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR,   •   s    c          O   s   t  i |  | Ž  d  S(   N(   RG   R.   (   RH   RI   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR.   ™   s    c          O   s   t  i |  | Ž  d  S(   N(   RG   R2   (   RH   RI   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR2      s    c          O   s   t  i |  | Ž  d  S(   N(   RG   R4   (   RH   RI   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR4   ¡   s    c           C   s    t  i t  i t i d ƒ ƒ d S(   sÓ   
   Called when a server command is used, this function gives a list of
   current server commands and the server command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   i    N(   RG   R   R	   R   R5   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   callbackServer§   s    t   _cmdlibt   serverc           C   s&   t  i t  i t i d ƒ i ƒ  ƒ d S(   sÊ   
   Called when a say command is used, this function gives a list of
   current say commands and the say command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   i    N(   RG   R   R
   R   R5   R#   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   callbackSay°   s    R   c           C   s&   t  i t  i t i d ƒ i ƒ  ƒ d S(   sÓ   
   Called when a client command is used, this function gives a list of
   current client commands and the client command used to cmd_manager.callback,
   which in turn decides a function should be executed.
   i    N(   RG   R   R   R   R5   R#   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyt   callbackClient¹   s    R/   R   c           B   s    e  Z d  Z d „  Z d „  Z RS(   sF    This class stores the name and callback function of a server command c         C   s   | |  _  | |  _ d  S(   N(   R   R   (   R   R   R   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR   È   s    	c         C   s5   t  |  i ƒ o |  i | ƒ n t i |  i ƒ d S(   sN    When told to execute a function we only need to pass the command's arguments N(   R<   R   R   t   doblock(   R   t   args(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR8   Ì   s    (   R   R   R   R   R8   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR   Æ   s   	R%   c           B   s/   e  Z d  Z d Z d Z d „  Z d d „ Z RS(   s   
   This class stores the name and callback functions of say or client commands
   It authorizes player as needed before function execution
   c         C   sé   t  i ƒ  } |  i d j	 oŽ t i d ƒ i | |  i ƒ } | pe |  i o8 t |  i ƒ o |  i | | ƒ qž t  i	 |  i ƒ n t  i
 | d |  i d ƒ d Sqª n t |  i ƒ o |  i | | ƒ n t  i i d |  i ƒ d S(   sç   
      When told to execute the function we need to pass the userid of the player who used the command
      as well as the command's arguments. We also need to determine if the player is authorized to
      use the command.
      R>   s"   You are not authorized to use the s	    command.Ns   es_xdoblock (   R   t   getcmduseridR(   R"   R@   t   uset   isUseridAuthorizedR*   R<   RO   t   tellR   R   RL   t   queuecmd(   R   RP   t   useridt	   is_authed(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR8   Ü   s    
c         C   s/   t  i d ƒ i | | ƒ | |  _ | |  _ d S(   s8    Sets permission information for say or client commands R>   N(   R@   RR   t   registerCapabilityR(   R*   (   R   R(   R)   R*   (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR&   ø   s    	N(   R   R   R   R"   R(   R*   R8   R&   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR%   Ô   s
   	c         C   sY   t  |  t ƒ o |  Sn t i d ƒ i |  ƒ } t  | t ƒ o | Sn t d |  ‚ d S(   s\   
   Converts a text permission level ('ROOT', 'ADMIN', etc) to its
   integer equivalent
   R>   s#   '%s' is not a valid auth permissionN(   R=   t   intR@   RR   t   __getattribute__R   (   t
   permissiont   value(    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pyR'     s    (   R   R@   t   psycot   fullt   objectR    RG   R   R   R   R,   R.   R2   R4   RJ   t   addonst   registerBlockRM   RN   R   R%   R'   (    (    (    sM   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/cmdlib.pys   <module>   s6   
|										-	R