ó
[³XMc           @   s÷  d  Z  d d l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d0 d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e 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* d1 d+ „  ƒ  YZ d, d2 d- „  ƒ  YZ d. d3 d/ „  ƒ  YZ d S(4   s€   
Form-based method objects.

This module contains support for descriptive method signatures that can be used
to format methods.
iÿÿÿÿNt   FormExceptionc           B   s   e  Z d  Z d „  Z RS(   s/   An error occurred calling the form method.
    c         O   s   t  j |  | Œ | |  _ d  S(   N(   t	   Exceptiont   __init__t   descriptions(   t   selft   argst   kwargs(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR      s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR       s   t
   InputErrorc           B   s   e  Z d  Z RS(   s,   
    An error occurred with some input.
    (   R   R   R	   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR
      s   t   Argumentc           B   s\   e  Z d  Z d Z d d d d d d „ Z d „  Z d d „ Z d „  Z d „  Z	 d „  Z
 RS(	   s   Base class for form arguments.i   c         C   sa   | |  _  | |  _ | d  k r* |  j } n  | |  _ | |  _ | |  _ | sT i  } n  | |  _ d  S(   N(   t   namet	   allowNonet   Nonet   defaultDefaultt   defaultt	   shortDesct   longDesct   hints(   R   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   #   s    						c         K   s   |  j  j | ƒ d  S(   N(   R   t   update(   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   addHints0   s    c         C   s   |  j  j | | ƒ S(   N(   R   t   get(   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   getHint3   s    c         C   s   |  j  p |  j j ƒ  S(   N(   R   R   t
   capitalize(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   getShortDescription6   s    c         C   s   |  j  p d S(   Nt    (   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   getLongDescription9   s    c         C   s   t  d ‚ d S(   s(   Convert the value to the correct format.s   implement in subclassN(   t   NotImplementedError(   R   t   val(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   coerce<   s    N(   R   R   R	   R   R   R   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR      s   			t   Stringc           B   sG   e  Z d  Z d Z d Z d Z d d d d d d d d „ Z d „  Z RS(   s   A single string.
    R   i    i   c	   	      C   sD   t  j |  | d | d | d | d | d | ƒ| |  _ | |  _ d  S(   NR   R   R   R   R   (   R   R   t   mint   max(	   R   R   R   R   R   R   R   R    R!   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   H   s    	c         C   su   t  | ƒ } t | ƒ |  j k  r4 t d |  j ‚ n  |  j d  k rk t | ƒ |  j k rk t d |  j ‚ n  t  | ƒ S(   Ns)   Value must be at least %s characters longs(   Value must be at most %s characters long(   t   strt   lenR    R
   R!   R   (   R   R   t   s(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   O   s    $N(	   R   R   R	   R   R    R   R!   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   A   s   t   Textc           B   s   e  Z d  Z RS(   s   A long string.
    (   R   R   R	   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR%   X   s   t   Passwordc           B   s   e  Z d  Z RS(   s2   A string which should be obscured when input.
    (   R   R   R	   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR&   ]   s   t   VerifiedPasswordc           B   s   e  Z d  Z d „  Z RS(   sC   A string that should be obscured when input and needs verification.c         C   s¥   t  | ƒ d k s& | d | d k r2 t d ‚ n  t | d ƒ } t  | ƒ |  j k  rj t d |  j ‚ n  |  j d  k r¡ t  | ƒ |  j k r¡ t d |  j ‚ n  | S(   Ni   i    i   s%   Please enter the same password twice.s)   Value must be at least %s characters longs(   Value must be at most %s characters long(   R#   R
   R"   R    R!   R   (   R   t   valsR$   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   e   s    &$(   R   R   R	   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR'   b   s   t   Hiddenc           B   s   e  Z d  Z RS(   sS   A string which is not displayed.

    The passed default is used as the value.
    (   R   R   R	   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR)   p   s   t   Integerc           B   s5   e  Z d  Z d Z d d d d d d „ Z d „  Z RS(   s   A single integer.
    i   c         C   s#   t  j |  | | | | | | ƒ d  S(   N(   R   R   (   R   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   |   s    c         C   sM   | j  ƒ  r |  j r d  Sy t | ƒ SWn t k
 rH t d | ‚ n Xd  S(   Ns5   %s is not valid, please enter a whole number, e.g. 10(   t   stripR   R   t   intt
   ValueErrorR
   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   †   s    N(   R   R   R	   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR*   w   s
   		t   IntegerRangec           B   s)   e  Z d  d d d d d „ Z d „  Z RS(   i   c	   	      C   sD   | |  _  | |  _ t j |  | d | d | d | d | d | ƒd  S(   NR   R   R   R   R   (   R    R!   R*   R   (	   R   R   R    R!   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ‘   s    		!c         C   s   t  j |  | ƒ } |  j r+ | d  k r+ | S| |  j k  rS t d | |  j f ‚ n  | |  j k r{ t d | |  j f ‚ n  | S(   Ns/   Value %s is too small, it should be at least %ss.   Value %s is too large, it should be at most %s(   R*   R   R   R   R    R
   R!   (   R   R   t   result(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ˜   s    N(   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR.      s   	t   Floatc           B   s/   e  Z d Z d  d d d d d „ Z d „  Z RS(   i   c         C   s#   t  j |  | | | | | | ƒ d  S(   N(   R   R   (   R   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   §   s    c         C   sM   | j  ƒ  r |  j r d  Sy t | ƒ SWn t k
 rH t d | ‚ n Xd  S(   Ns   Invalid float: %s(   R+   R   R   t   floatR-   R
   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ²   s    N(   R   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR0   £   s   	
t   Choicec           B   s2   e  Z d  Z g  g  d d d d d „ Z d „  Z RS(   sÐ  
    The result of a choice between enumerated types.  The choices should
    be a list of tuples of tag, value, and description.  The tag will be
    the value returned if the user hits "Submit", and the description
    is the bale for the enumerated type.  default is a list of all the
    values (seconds element in choices).  If no defaults are specified,
    initially the first item will be selected.  Only one item can (should)
    be selected at once.
    i   c      
   C   sT   | |  _  | r. | r. | j | d d ƒ n  t j |  | | | | | d | ƒd  S(   Ni    i   R   (   t   choicest   appendR   R   (   R   R   R3   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   Å   s    	c         C   sA   x: |  j  D] \ } } } | | k r
 | Sq
 Wt d | ƒ ‚ d  S(   Ns   Invalid Choice: %s(   R3   R
   (   R   t   inIdentt   identR   t   desc(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   Ì   s    N(   R   R   R	   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR2   »   s   		t   Flagsc           B   s2   e  Z d  Z d d d d d d d „ Z d „  Z RS(   s¸  
    The result of a checkbox group or multi-menu.  The flags should be a
    list of tuples of tag, value, and description. The tag will be
    the value returned if the user hits "Submit", and the description
    is the bale for the enumerated type.  default is a list of all the
    values (second elements in flags).  If no defaults are specified,
    initially nothing will be selected.  Several items may be selected at
    once.
    i   c      	   C   s/   | |  _  t j |  | | | | | d | ƒd  S(   NR   (   t   flagsR   R   (   R   R   R9   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   Þ   s    	c         C   so   | s
 g  Sg  } xX | D]P } xG |  j  D], \ } } } | | k r' | j | ƒ Pq' q' Wt d | ƒ ‚ q W| S(   Ns   Invalid Flag: %s(   R9   R4   R
   (   R   t
   inFlagKeyst   outFlagst	   inFlagKeyt   flagKeyt   flagValt   flagDesc(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ã   s    (    (    N(   R   R   R	   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR8   Ô   s   		t
   CheckGroupc           B   s   e  Z RS(    (   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR@   ñ   s   t
   RadioGroupc           B   s   e  Z RS(    (   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRA   õ   s   t   Booleanc           B   s   e  Z d  „  Z RS(   c         C   s0   | s
 d St  | ƒ j ƒ  } | d k r, d Sd S(	   Ni    t   not   nt   ft   falset   0i   (   RC   RD   RE   RF   RG   (   R"   t   lower(   R   t   inValt   lInVal(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ú   s    (   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRB   ù   s   t   Filec           B   s&   e  Z d  d d d d „ Z d „  Z RS(   i   c         C   s)   | |  _  t j |  | d  | | | ƒ d  S(   N(   R   R   R   R   (   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR     s    	c         C   s+   | r |  j  r d  S| r | St d ‚ d  S(   Ns   Invalid File(   R   R   R
   (   R   t   file(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR     s
    N(   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRK     s   	c         C   s%   t  |  ƒ }  |  d k r! t ‚ n  |  S(   Ni    (   R,   R-   (   t   x(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   positiveInt  s     	t   Datec           B   s5   e  Z d  Z d Z d d d d d d „ Z d „  Z RS(   s#   A date -- (year, month, day) tuple.i   c         C   s;   t  j |  | | | | | ƒ | |  _ | s7 d |  _ n  d  S(   Ni²  i   (   i²  i   i   (   R   R   R   R   (   R   R   R   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR     s    	c         C   sì   t  | ƒ d k r |  j r d Sy t t | ƒ \ } } } Wn t k
 rW t d ‚ n X| | f d k r™ t j | ƒ s‰ t d | ‚ q™ | | | f Sn  y t j	 | } Wn t
 k
 rÆ t d ‚ n X| | k rß t d ‚ n  | | | f S(	   s(   Return tuple of ints (year, month, day).R   s   Invalid datei   i   s   %d was not a leap year(   R   R   R   N(   i   i   (   t   tupleR   R   t   mapRN   R-   R
   t   calendart   isleapt   mdayst
   IndexError(   R   R   t   yeart   montht   dayRT   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   !  s"    N(   R   R   R	   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRO     s
   	t   Submitc           B   s5   e  Z d  Z d g d d d d d d „ Z d „  Z RS(	   s0   Submit button or a reasonable facsimile thereof.RY   t   submits   Submit formi    c         C   s>   t  j |  | d | d | d | d | ƒ| |  _ | |  _ d  S(   NR3   R   R   R   (   R2   R   R   t   reset(   R   R   R3   R[   R   R   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   ;  s    	c         C   s(   |  j  r | r d  St j |  | ƒ Sd  S(   N(   R   R   R2   R   (   R   t   value(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   B  s    (   s   SubmitRZ   s   Submit formN(   R   R   R	   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRY   8  s   t   PresentationHintc           B   s   e  Z d  Z RS(   s(   
    A hint to a particular system.
    (   R   R   R	   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR]   I  s   t   MethodSignaturec           B   s&   e  Z d  „  Z d „  Z e d „ Z RS(   c         G   s   | |  _  d S(   s	   
        N(   t   methodSignature(   R   t   sigList(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   Q  s    c         C   s+   x$ |  j  D] } | j | k r
 | Sq
 Wd  S(   N(   R_   R   (   R   R   t   a(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   getArgumentV  s    c         C   s   t  |  | | ƒ S(   N(   t
   FormMethod(   R   t   callablet   takesRequest(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   method[  s    (   R   R   R   Rb   t   FalseRf   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR^   O  s   		Rc   c           B   s,   e  Z d  Z e d „ Z d „  Z d „  Z RS(   s#   A callable object with a signature.c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t	   signatureRd   Re   (   R   Rh   Rd   Re   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyR   b  s    		c         C   s   t  |  j j ƒ S(   N(   RP   Rh   R_   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   getArgsg  s    c         O   s   |  j  | | Ž  S(   N(   Rd   (   R   R   t   kw(    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   callj  s    (   R   R   R	   Rg   R   Ri   Rk   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyRc   _  s   	(    (    (    (    (   R	   RR   R   R    R
   R   R   R%   R&   R'   R)   R*   R.   R0   R2   R8   R@   RA   RB   RK   RN   RO   RY   R]   R^   Rc   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/python/formmethod.pyt   <module>   s0   $		#