³ò
šõÜNc           @   sã   d  d k  Z  d  d k Z e  i ƒ  Z d e _ d e _ d e _ d e _ d e _ d Z	 d Z
 d	 Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ e ƒ  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d S(   iÿÿÿÿNs%   Repeat2 - EventScripts python libraryt   sushi01s*   http://www.eventscripts.com/pages/Repeat2/t   repeat2s$   SumGuy14 (Aka SoccerDude) & XE_ManUpi   i   i   t   RepeatErrorc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t   msg(   t   selfR   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   __init__   s    c         C   s   t  |  i ƒ S(   N(   t   reprR   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   __str__"   s    (   t   __name__t
   __module__R   R   (    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR      s   	t   RepeatContainerc           B   s    e  Z d  Z d „  Z d „  Z RS(   sª   Dictionary object that contains all repeat instances. The keys of the
    dictionary are the repeat names and the Repeat() instances are the values
    of the keys.

    c         C   s?   | |  j o | |  | <n! t  d | d d d | ƒ ‚ d S(   s1   Adds a repeat instance by name to the dictionary.s%   The repeat name "%s" already exists! s9   If you are creating a new repeat, please use a different s1   name. If you are updating the repeat, please use s   repeat.find("%s").N(   R   (   R   t   namet   instance(    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   add,   s
    c         C   s%   y |  | =Wn t  j
 o n Xd S(   s5   Deletes a repeat instance by name from the container.N(   t   KeyError(   R   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   delete7   s    (   R   R	   t   __doc__R   R   (    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR
   &   s   	t   RepeatManagerc           B   sò   e  Z d  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sü   Class that controls interaction with the repeat such as starting,
    stopping, pausing, resuming, etc.

    Arguments:
        instance_or_name: This can be either a Repeat() instance, or the name
                          given to the instance.

    c         C   s   t  | t ƒ pF t t | ƒ ƒ } | d  j o t d | ƒ ‚ n t | ƒ |  _ n
 | |  _ d |  _ d |  _ d |  _	 d |  _
 t |  _ d  S(   Ns%   The repeat name "%s" can not be foundi    (   t
   isinstancet   Repeatt   findt   strt   NoneR   t   repeatt	   _adjustedt   _countt	   _intervalt   _limitt   STATUS_STOPPEDt   _status(   R   t   instance_or_nameR   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   P   s    					c         C   s   t  |  t | ƒ i ƒ  ƒ S(   N(   t   getattrR   t   lower(   R   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   __getitem__d   s    c         C   s   |  i  | | ƒ d  S(   N(   t   __setattr__(   R   R   t   value(    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   __setitem__h   s    c         C   s   |  i  |  i S(   s@   Returns the amount of time (in seconds) remaining in the repeat.(   t	   remainingR   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   timelefto   s    c         C   s1   |  i  p |  i |  i Sn |  i |  i |  i  S(   s9   Returns the amount of time (in seconds) that has elapsed.(   R   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   elapsedt   s    
c         C   s8   |  i  p |  i |  i Sn |  i |  i |  i  |  i S(   sd   Returns the total amount of time (in seconds) it will take to
        complete the repeat.

        (   R   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   time}   s    
c         C   s   |  i  |  i S(   s4   Returns the number of loops remaining in the repeat.(   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR%   Š   s    c         C   s#   |  i  p |  i Sn |  i |  i  S(   s6   Returns the number of loops that the repeat has fired.(   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   count   s    
c         C   s   t  i S|  i S(   s~   Returns the status of the repeat:

        STATUS_STOPPED == 1
        STATUS_RUNNING == 2
        STATUS_PAUSED == 3
        (   R   t   statusR   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR*   ˜   s    c         C   s   |  i  S(   s8   Returns the delay between each time the repeat is fired.(   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   interval£   s    c         C   s   |  i  S(   s5   Returns the number of times the repeat will run/loop.(   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   limit¨   s    c         C   se   |  i  t j o |  i ƒ  n d |  _ d |  _ t | ƒ |  _ t | ƒ |  _ t |  _	 |  i
 ƒ  d S(   s“  Starts the repeatable command.

        Arguments:
            interval: Float value which represents the delay between each time
                      the repeat is fired.
            limit: Integer value which represents the number of times to loop.
                   If 0, the repeat will continue to loop indefinately until
                   stopped.

        Note:
            * If starting an already running repeat, this will stop the
              currently running repeat, and restart with the newly passed
              values.
            * If starting a paused repeat, this restart the repeat with the
              newly passed values.
        i    N(   R*   t   STATUS_RUNNINGt   stopR   R   t   floatR   t   intR   R   t   _fire(   R   R+   R,   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   start°   s    			c         C   s)   d |  _  d |  _ t |  _ |  i ƒ  d S(   s9  Restarts the repeat based on the stored interval and limit
        arguments.

        Note:
            * It is assumed that the start() method was used prior to utilizing
              this method. If both the interval and limit have values of 0,
              this method will not restart the repeat.

        i    N(   R   R   R-   R   R1   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   restartÏ   s    			c         C   s)   t  i |  i i ƒ t |  _ d |  _ d S(   sf  Stops the execution of the repeat.

        Note:
            * By stopping the repeat, it effectly cancels all pending actions.
            * Once stopped, the repeat must be started using the start() or
              restart() methods.
            * Use the pause() method if needing to resume the repeat from
              where it was left off.

        i    N(   t
   gamethreadt   cancelDelayedR   R   R   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR.   á   s    	c         C   s8   |  i  t j o d Sn t |  _  t i |  i i ƒ d S(   sÎ   Pauses a repeat for continued execution at a later time.

        Note:
            * Repeat must be running (status == 2) to pause.
            * To resume paused repeat, use the resume() method.

        N(   R   R-   t   STATUS_PAUSEDR4   R5   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   pauseõ   s    		c         C   sc   |  i  t j o d Sn |  i d j o |  i d j p |  i d j o t |  _  |  i ƒ  n d S(   s  Resumes a paused repeat.

        Note:
            * Only to be used for resuming a paused repeat.
            * If needing to restart a repeat from the beginning, use the
              start() method.
            * A paused repeat will show a status of 3 (PAUSE).

        Ni    (   R   R-   R   R%   R1   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   resume  s     	c         C   s5   |  i  t j o |  i ƒ  n t i |  i i ƒ d S(   so  Deletes the repeat from its stored location in the container. When
        deleting the repeat, the repeat is stopped. The intention of this
        method is that it is to be used for cleanup purposes. Since the repeat
        instance is saved in a container, it is pertinent that you delete your
        created repeat when your script/addon is unloaded.

        N(   R   R-   R.   t   repeatContainerR   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR     s    	c         C   sw   |  i  d j o d Sn t t | ƒ |  i ƒ } |  i p |  i | 7_ n |  i | |  i 7_ |  i | 8_ d S(   s—   Extends the amount of time (in seconds) that the repeat will run.

        Note:
            * Time can not be extended if limit is set to 0.

        i    N(   R   R0   R   R   R   (   R   t   secondsR)   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   extend.  s    
c         C   sw   |  i  d j o d Sn t t | ƒ |  i ƒ } |  i p |  i | 7_ n |  i | |  i 7_ |  i | 7_ d S(   s—   Reduces the amount of time (in seconds) that the repeat will run.

        Note:
            * Time can not be extended if limit is set to 0.

        i    N(   R   R0   R   R   R   (   R   R:   R)   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   reduceF  s    
c         C   sÙ   |  i  |  i j  p |  i d j o¨ |  i  d 7_  t |  i i ƒ o8 t i |  i |  i i |  i i |  i i	 |  i i
 ƒ n, t i |  i |  i i t i i |  i i ƒ t i |  i |  i i |  i ƒ n |  i ƒ  d  S(   Ni    i   (   R   R   t   callableR   t   commandR4   t   delayednameR   R   t   argst   kwargst   est   servert   queuecmdR1   R.   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR1   ]  s    #(   R   R	   R   R   R!   R$   t   propertyR&   R'   R(   R%   R)   R*   R+   R,   R2   R3   R.   R7   R8   R   R;   R<   R1   (    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   D   s*   													R   c           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s-   Class that contains the intial repeat object.c         O   sQ   t  | ƒ |  _ | |  _ | |  _ | |  _ t i |  |  ƒ t i |  i |  ƒ d  S(   N(	   R   R   R>   R@   RA   R   R   R9   R   (   R   R   R>   R@   RA   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   y  s    			c         C   s   t  |  t | ƒ i ƒ  ƒ S(   N(   R   R   R    (   R   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR!   †  s    c         C   s   |  i  | | ƒ d  S(   N(   R"   (   R   R   R#   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR$   Š  s    c         C   sb   | d j o> t  |  | ƒ o* t i t | ƒ |  ƒ t i |  i ƒ qK n t i |  | | ƒ d  S(   NR   (   t   hasattrR9   R   R   R   R   t   objectR"   (   R   R   R#   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR"   Ž  s
    c         C   s   t  |  i ƒ S(   N(   R   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   ˜  s    (   R   R	   R   R   R!   R$   R"   R   (    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   t  s   				
c         C   s   |  t  j o t  |  Sn d S(   s¼   Finds and returns a repeat by its name.

    Note:
        * Returns a Repeat() class instance if the name is found.
        * Returns None if a Repeat() class instance is not found.

    N(   R9   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   Ÿ  s    c         C   s   t  i |  ƒ d S(   s   Deletes a repeat by name.N(   R9   R   (   R   (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyR   ­  s    c           C   s
   t  i ƒ  S(   s3   Returns a list of all existing/stored repeat names.(   R9   t   keys(    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pyt   get_repeat_names²  s    (   RB   R4   t	   AddonInfot   infoR   t   versiont   urlt   basenamet   authorR   R-   R6   t	   ExceptionR   t   dictR
   R9   RG   R   R   R   R   RI   (    (    (    sV   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/repeat/repeat.pys   <module>   s&   						ÿ 1+		