ó
BqzRc           @   s    d  Z  d e f d „  ƒ  YZ d S(   s)   
A switch with three states: on|off|auto
t   Tristatec           B   sz   e  Z d  Z e Z e Z d Z d d d d d g Z d „  Z	 d „  Z
 e d	 „  ƒ Z d
 „  Z d „  Z d „  Z d „  Z RS(   s!   Tri-state value: on, off or auto iÿÿÿÿt   ont   offt   truet   falset   autoc         C   s  t  | ƒ g  t d f D] } t  | ƒ ^ q k rv | d k rL |  j |  _ q| d k  rg |  j |  _ q|  j |  _ n£ t  | ƒ g  d D] } t  | ƒ ^ q† k rò | j ƒ  d	 k rÂ |  j |  _ q| j ƒ  d
 k rã |  j |  _ q|  j |  _ n' t  | ƒ t k r| j |  _ n t	 ‚ d  S(   Ni   i    t    u    R   R   R   (   R   u    (   R   R   (   R   (
   t   typet   Truet   ONt   _statet   AUTOt   OFFt   lowerR    t   statet	   TypeError(   t   selft   valt   t(    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   __init__   s    1+c         C   s4   |  j  |  j k r d S|  j  |  j k r, d Sd Sd S(   sÛ   
        >>> Tristate('on').__repr__()
        'on'
        >>> Tristate(True).__repr__()
        'on'
        >>> Tristate(False).__repr__()
        'off'
        >>> Tristate('auto').__repr__()
        'auto'
        R   R   R   N(   R
   R	   R   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   __repr__3   s
    c         C   s   |  j  S(   s   Get current state(   R
   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyR   E   s    c         C   s   t  t g |  j |  j k S(   N(   t   FalseR   R
   R   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   is_autoJ   s    c         C   s   t  t g |  j |  j k S(   N(   R   R   R
   R	   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   is_onM   s    c         C   s   t  t g |  j |  j k S(   N(   R   R   R
   R   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   is_offP   s    c         O   s=   |  j  ƒ  r t S| | | Ž  } | s9 t t g |  j ƒ  St S(   s   
        Run function if tristate is on or auto, only report a failure if
        tristate is on since failing is o.k. for autodetect.
        (   R   R   R   R   (   R   t   functiont   argst   kwargst   success(    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   doS   s    (   t   __name__t
   __module__t   __doc__R   R	   R   R   R   t   _VALID_NAMESR   R   t   propertyR   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyR       s   					N(   R    t   objectR    (    (    (    s0   /usr/lib/python2.7/dist-packages/gbp/tristate.pyt   <module>   s   