๓
pฏ[Rc           @`  sm  d  Z  d d l m Z m Z d d d d d d g Z d d	 l m Z d d
 l m Z d d l	 m
 Z
 m Z m Z e   Z e e e    Z d e f d     YZ d e f d     YZ d e d e f i   f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d e f d     YZ d e f d     YZ d S(   si   
Symbolic constant support, including collections and constants with text,
numeric, and bit flag values.
i    (   t   divisiont   absolute_importt   NamedConstantt   ValueConstantt   FlagConstantt   Namest   Valuest   Flags(   t   partial(   t   count(   t   and_t   or_t   xort	   _Constantc           B`  s)   e  Z d  Z d   Z d   Z d   Z RS(   sท  
    @ivar _index: A C{int} allocated from a shared counter in order to keep
        track of the order in which L{_Constant}s are instantiated.

    @ivar name: A C{str} giving the name of this constant; only set once the
        constant is initialized by L{_ConstantsContainer}.

    @ivar _container: The L{_ConstantsContainer} subclass this constant belongs
        to; C{None} until the constant is initialized by that subclass.
    c         C`  s   d  |  _ t   |  _ d  S(   N(   t   Nonet
   _containert   _constantOrdert   _index(   t   self(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __init__#   s    	c         C`  s   d |  j  j |  j f S(   sq   
        Return text identifying both which constant this is and which collection
        it belongs to.
        s   <%s=%s>(   R   t   __name__t   name(   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __repr__(   s    c         C`  s   | |  _  | |  _ d S(   so  
        Complete the initialization of this L{_Constant}.

        @param container: The L{_ConstantsContainer} subclass this constant is
            part of.

        @param name: The name of this constant in its container.

        @param value: The value of this constant; not used, as named constants
            have no value apart from their identity.
        N(   R   R   (   R   t	   containerR   t   value(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   _realize0   s    	(   R   t
   __module__t   __doc__R   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR      s   
		t   _ConstantsContainerTypec           B`  s   e  Z d  Z d   Z RS(   sa   
    L{_ConstantsContainerType} is a metaclass for creating constants container
    classes.
    c         C`  s!  t  t |   j |  | | |  } t | d d  } | d k rC | Sg  } xs | j   D]e \ } } t | | j  rV | j d k	 r t	 d | | j
 f   n  | j | j | | f  qV qV Wi  } xL t |  D]> \ }	 }
 } | j |
 |  } | j | |
 |  | | |
 <qา W| | _ | S(   s  
        Create a new constants container class.

        If C{attributes} includes a value of C{None} for the C{"_constantType"}
        key, the new class will not be initialized as a constants container and
        it will behave as a normal class.

        @param name: The name of the container class.
        @type name: L{str}

        @param bases: A tuple of the base classes for the new container class.
        @type bases: L{tuple} of L{_ConstantsContainerType} instances

        @param attributes: The attributes of the new container class, including
            any constants it is to contain.
        @type attributes: L{dict}
        t   _constantTypes0   Cannot use %s as the value of an attribute on %sN(   t   superR   t   __new__t   getattrR   t   itemst
   isinstanceR   R   t
   ValueErrorR   t   appendR   t   sortedt   _constantFactoryR   t   _enumerants(   R   R   t   basest
   attributest   clst   constantTypet	   constantst
   descriptort
   enumerantst   indext	   enumerantR   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   F   s(     	(   R   R   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   A   s   t   _ConstantsContainert    c           B`  sJ   e  Z d  Z d Z d   Z e d    Z e d    Z e d    Z	 RS(   sี  
    L{_ConstantsContainer} is a class with attributes used as symbolic
    constants.  It is up to subclasses to specify what kind of constants are
    allowed.

    @cvar _constantType: Specified by a L{_ConstantsContainer} subclass to
        specify the type of constants allowed by that subclass.

    @cvar _enumerants: A C{dict} mapping the names of constants (eg
        L{NamedConstant} instances) found in the class definition to those
        instances.
    c         C`  s   t  d |  j f   d S(   s   
        Classes representing constants containers are not intended to be
        instantiated.

        The class object itself is used directly.
        s   %s may not be instantiated.N(   t	   TypeErrorR   (   R*   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR      s    c         C`  s   t  S(   s  
        Construct the value for a new constant to add to this container.

        @param name: The name of the constant to create.

        @param descriptor: An instance of a L{_Constant} subclass (eg
            L{NamedConstant}) which is assigned to C{name}.

        @return: L{NamedConstant} instances have no value apart from identity,
            so return a meaningless dummy value.
        (   t   _unspecified(   R*   R   R-   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR&      s    c         C`  s,   | |  j  k r t |  |  St |   d S(   s  
        Retrieve a constant by its name or raise a C{ValueError} if there is no
        constant associated with that name.

        @param name: A C{str} giving the name of one of the constants defined by
            C{cls}.

        @raise ValueError: If C{name} is not the name of one of the constants
            defined by C{cls}.

        @return: The L{NamedConstant} associated with C{name}.
        N(   R'   R    R#   (   R*   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   lookupByNameช   s    c         C`  s(   |  j  j   } t t | d d    S(   s๛   
        Iteration over a L{Names} subclass results in all of the constants it
        contains.

        @return: an iterator the elements of which are the L{NamedConstant}
            instances defined in the body of this L{Names} subclass.
        t   keyc         S`  s   |  j  S(   N(   R   (   R-   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   <lambda>ษ   s    (   R'   t   valuest   iterR%   (   R*   R,   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   iterconstantsฝ   s    	N(
   R   R   R   R   R   R   t   classmethodR&   R5   R:   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR1      s   	
c           B`  s   e  Z d  Z RS(   s  
    L{NamedConstant} defines an attribute to be a named constant within a
    collection defined by a L{Names} subclass.

    L{NamedConstant} is only for use in the definition of L{Names}
    subclasses.  Do not instantiate L{NamedConstant} elsewhere and do not
    subclass it.
    (   R   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   อ   s   c           B`  s   e  Z d  Z e Z RS(   se   
    A L{Names} subclass contains constants which differ only in their names and
    identities.
    (   R   R   R   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   ู   s   c           B`  s   e  Z d  Z d   Z RS(   s  
    L{ValueConstant} defines an attribute to be a named constant within a
    collection defined by a L{Values} subclass.

    L{ValueConstant} is only for use in the definition of L{Values} subclasses.
    Do not instantiate L{ValueConstant} elsewhere and do not subclass it.
    c         C`  s   t  j |   | |  _ d  S(   N(   R   R   R   (   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   ๊   s    (   R   R   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   โ   s   c           B`  s#   e  Z d  Z e Z e d    Z RS(   sa   
    A L{Values} subclass contains constants which are associated with arbitrary
    values.
    c         C`  s:   x' |  j    D] } | j | k r | Sq Wt |   d S(   s  
        Retrieve a constant by its value or raise a C{ValueError} if there is no
        constant associated with that value.

        @param value: The value of one of the constants defined by C{cls}.

        @raise ValueError: If C{value} is not the value of one of the constants
            defined by C{cls}.

        @return: The L{ValueConstant} associated with C{value}.
        N(   R:   R   R#   (   R*   R   t   constant(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   lookupByValue๗   s    (   R   R   R   R   R   R;   R=   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   ๐   s   c         C`  sM   |  | j  | j   } |  | j | j  } t   } | j | j | |  | S(   s  
    Implement a binary operator for a L{FlagConstant} instance.

    @param op: A two-argument callable implementing the binary operation.  For
        example, C{operator.or_}.

    @param left: The left-hand L{FlagConstant} instance.
    @param right: The right-hand L{FlagConstant} instance.

    @return: A new L{FlagConstant} instance representing the result of the
        operation.
    (   R   t   namesR   R   R   (   t   opt   leftt   rightR   R>   t   result(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   _flagOp  s
    	c           B`  sh   e  Z d  Z e d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z e Z RS(
   s  
    L{FlagConstant} defines an attribute to be a flag constant within a
    collection defined by a L{Flags} subclass.

    L{FlagConstant} is only for use in the definition of L{Flags} subclasses.
    Do not instantiate L{FlagConstant} elsewhere and do not subclass it.
    c         C`  s   t  j |   | |  _ d  S(   N(   R   R   R   (   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   (  s    c         C`  s   t  | t  r' | } t | g  } n; t |  d k rE | \ } n d d j t |   d } t j |  | | |  | |  _ | |  _	 d S(   sQ  
        Complete the initialization of this L{FlagConstant}.

        This implementation differs from other C{_realize} implementations in
        that a L{FlagConstant} may have several names which apply to it, due to
        flags being combined with various operators.

        @param container: The L{Flags} subclass this constant is part of.

        @param names: When a single-flag value is being initialized, a C{str}
            giving the name of that flag.  This is the case which happens when a
            L{Flags} subclass is being initialized and L{FlagConstant} instances
            from its body are being realized.  Otherwise, a C{set} of C{str}
            giving names of all the flags set on this L{FlagConstant} instance.
            This is the case when two flags are combined using C{|}, for
            example.
        i   t   {t   ,t   }N(
   R"   t   strt   sett   lent   joinR%   R   R   R   R>   (   R   R   R>   R   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR   -  s    	c         C`  s   t  t |  |  S(   s   
        Define C{|} on two L{FlagConstant} instances to create a new
        L{FlagConstant} instance with all flags set in either instance set.
        (   RC   R   (   R   t   other(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __or__K  s    c         C`  s   t  t |  |  S(   s   
        Define C{&} on two L{FlagConstant} instances to create a new
        L{FlagConstant} instance with only flags set in both instances set.
        (   RC   R
   (   R   RK   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __and__S  s    c         C`  s   t  t |  |  S(   sจ   
        Define C{^} on two L{FlagConstant} instances to create a new
        L{FlagConstant} instance with only flags set on exactly one instance
        set.
        (   RC   R   (   R   RK   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __xor__[  s    c         C`  sc   t    } | j |  j t   d  x: |  j j   D]) } | j |  j @d k r2 | | O} q2 q2 W| S(   s   
        Define C{~} on a L{FlagConstant} instance to create a new
        L{FlagConstant} instance with all flags not set on this instance set.
        i    (   R   R   R   RH   R:   R   (   R   RB   t   flag(    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt
   __invert__d  s    	c         `  s     f d     j  D S(   sI   
        @return: An iterator of flags set on this instance set.
        c         3`  s!   |  ] }   j  j |  Vq d  S(   N(   R   R5   (   t   .0R   (   R   (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pys	   <genexpr>u  s    (   R>   (   R   (    (   R   sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __iter__q  s    c         C`  s   t  | |  @ S(   sน   
        @param flag: The flag to test for membership in this instance
            set.

        @return: C{True} if C{flag} is in this instance set, else
            C{False}.
        (   t   bool(   R   RO   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __contains__x  s    	c         C`  s   t  |  j  S(   sL   
        @return: C{False} if this flag's value is 0, else C{True}.
        (   RS   R   (   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   __nonzero__  s    (   R   R   R   R4   R   R   RL   RM   RN   RP   RR   RT   RU   t   __bool__(    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR      s   									c           B`  s)   e  Z d  Z e Z d Z e d    Z RS(   sต   
    A L{Flags} subclass contains constants which can be combined using the
    common bitwise operators (C{|}, C{&}, etc) similar to a I{bitvector} from a
    language like C.
    i   c         C`  sD   | j  t k r* |  j } |  j d K_ n | j  } | d >|  _ | S(   s
  
        For L{FlagConstant} instances with no explicitly defined value, assign
        the next power of two as its value.

        @param name: The name of the constant to create.

        @param descriptor: An instance of a L{FlagConstant} which is assigned to
            C{name}.

        @return: Either the value passed to the C{descriptor} constructor, or
            the next power of 2 value which will be assigned to C{descriptor},
            relative to the value of the last defined L{FlagConstant}.
        i   (   R   R4   t   _value(   R*   R   R-   R   (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR&     s    		(   R   R   R   R   R   RW   R;   R&   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyR     s   N(   R   t
   __future__R    R   t   __all__t	   functoolsR   t	   itertoolsR	   t   operatorR
   R   R   t   objectR4   t   nextR   R   t   typeR   R1   R   R   R   R   RC   R   R   (    (    (    sJ   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/python/constants.pyt   <module>   s$   		)?%M		m