U
    +c[/                     @   sX  d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlZej	rZddl
mZ d{d	d
Zeede_d|ddZd}ddZG dd deZG dd dZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!ZG d"d# d#eZG d$d% d%eZG d&d' d'eZG d(d) d)eZG d*d+ d+eZG d,d- d-eZ G d.d/ d/eZ!G d0d1 d1eZ"G d2d3 d3eZ#G d4d5 d5eZ$G d6d7 d7eZ%G d8d9 d9eZ&G d:d; d;eZ'G d<d= d=eZ(G d>d? d?eZ)G d@dA dAeZ*G dBdC dCeZ+G dDdE dEeZ,G dFdG dGeZ-e.dHdIdJgZ/G dKdL dLe/Z0G dMdN dNeZ1e1 Z2G dOdP dPeZ3G dQdR dReZ4dSdT Z5dUdV Z6G dWdX dXe7Z8e8ddYdZZ9G d[d\ d\ej:Z;G d]d^ d^eZ<d~d`daZ=ddcddZ>dedf Z?G dgdh dheZ@G didj djeZAG dkdl dleZBdmdn ZCeCddpdqZDdrds ZEddtduZFddydzZGdS )zAThis module has components that are used for testing Python Fire.    )absolute_import)division)print_functionN)test_components_py3
      c                 O   s   | |||||fS N )arg1arg2arg3arg4Zarg5Zarg6r	   r	   8/tmp/pip-unpacked-wheel-1xt1w7un/fire/test_components.pyidentity   s    r   )r   r      c                 C   s   | | S )zMultiplies num by rate.

  Args:
    num (int): the num you want to multiply
    rate (int): the rate for multiplication
  Returns:
    Multiplication of num by rate
  r	   )numZrater	   r	   r   multiplier_with_docstring%   s    	r   Tc                 C   s   | S r   r	   )helpr	   r	   r   function_with_help1   s    r   c                   @   s   e Zd ZdS )EmptyN__name__
__module____qualname__r	   r	   r	   r   r   5   s   r   c                   @   s   e Zd ZdS )OldStyleEmptyNr   r	   r	   r	   r   r   9   s   r   c                   @   s   e Zd Zdd ZdS )WithInitc                 C   s   d S r   r	   selfr	   r	   r   __init__?   s    zWithInit.__init__Nr   r   r   r   r	   r	   r	   r   r   =   s   r   c                   @   s   e Zd ZdddZdS )ErrorInConstructorvaluec                 C   s   || _ tdd S )NzError in constructor)r!   
ValueErrorr   r!   r	   r	   r   r   E   s    zErrorInConstructor.__init__N)r!   r   r	   r	   r	   r   r    C   s   r    c                   @   s   e Zd ZdZdddZdS )WithHelpArgz2Test class for testing when class has a help= arg.Tc                 C   s   || _ ddi| _d S )NZ__helpzhelp in a dict)Zhas_help
dictionary)r   r   r	   r	   r   r   M   s    zWithHelpArg.__init__N)Tr   r   r   __doc__r   r	   r	   r	   r   r$   J   s   r$   c                   @   s   e Zd Zdd Zdd ZdS )
NoDefaultsc                 C   s   d| S Nr   r	   r   countr	   r	   r   doubleT   s    zNoDefaults.doublec                 C   s   d| S N   r	   r*   r	   r	   r   tripleW   s    zNoDefaults.tripleNr   r   r   r,   r/   r	   r	   r	   r   r(   R   s   r(   c                   @   s.   e Zd ZdZdddZdddZddd	Zd
S )WithDefaultsz1Class with functions that have default arguments.r   c                 C   s   d| S )zReturns the input multiplied by 2.

    Args:
      count: Input number that you want to double.

    Returns:
      A number that is the double of count.
    r   r	   r*   r	   r	   r   r,   ^   s    	zWithDefaults.doublec                 C   s   d| S r-   r	   r*   r	   r	   r   r/   i   s    zWithDefaults.tripleP00010203040506070809101112131415161718192021222324252627282930313233343536373839c                 C   s   |S r   r	   )r   stringr	   r	   r   textl   s    zWithDefaults.textN)r   )r   )r2   )r   r   r   r'   r,   r/   r4   r	   r	   r	   r   r1   [   s
   

 r1   c                   @   s    e Zd ZdddZdddZdS )	OldStyleWithDefaultsr   c                 C   s   d| S r)   r	   r*   r	   r	   r   r,   v   s    zOldStyleWithDefaults.doublec                 C   s   d| S r-   r	   r*   r	   r	   r   r/   y   s    zOldStyleWithDefaults.tripleN)r   )r   r0   r	   r	   r	   r   r5   t   s   
r5   c                   @   s(   e Zd Zdd Zd
ddZdddZd	S )MixedDefaultsc                 C   s   dS )Nr   r	   r   r	   r	   r   ten   s    zMixedDefaults.tenr   c                 C   s   |d|  S r)   r	   r   alphabetar	   r	   r   sum   s    zMixedDefaults.sum0c                 C   s   ||fS r   r	   r8   r	   r	   r   r      s    zMixedDefaults.identityN)r   r   )r<   )r   r   r   r7   r;   r   r	   r	   r	   r   r6   }   s   
r6   c                   @   s    e Zd ZdddZdddZdS )	SimilarArgNamesFc                 C   s   ||fS r   r	   )r   Zbool_oneZbool_twor	   r	   r   r      s    zSimilarArgNames.identityNc                 C   s   ||fS r   r	   )r   ar9   r	   r	   r   	identity2   s    zSimilarArgNames.identity2)FF)NN)r   r   r   r   r?   r	   r	   r	   r   r=      s   
r=   c                   @   s   e Zd ZdddZdS )CapitalizedArgNames      ?       @c                 C   s   || S r   r	   )r   DeltaGammar	   r	   r   r;      s    zCapitalizedArgNames.sumN)rA   rB   )r   r   r   r;   r	   r	   r	   r   r@      s   r@   c                   @   s4   e Zd ZdddZd	ddZdeie_deie_dS )
Annotationsr   c                 C   s   d| S r)   r	   r*   r	   r	   r   r,      s    zAnnotations.doublec                 C   s   d| S r-   r	   r*   r	   r	   r   r/      s    zAnnotations.tripler+   N)r   )r   )r   r   r   r,   r/   float__annotations__r	   r	   r	   r   rE      s   


rE   c                   @   s   e Zd ZdZdd ZdS )TypedPropertieszDTest class for testing Python Fire with properties of various types.c                 C   s@   d| _ d| _t | _ddddd| _dd	g| _d
| _d| _d S )NT)   r   r.   Er>   b)r   rI   )echoZnestZalexZbethany)ZcarrydivideZmyexcitingstring)r9   r:   r1   ZcharliedeltarL   Zfoxgammar   r	   r	   r   r      s    
zTypedProperties.__init__Nr&   r	   r	   r	   r   rH      s   rH   c                   @   s"   e Zd ZdZdd ZdddZdS )	VarArgsz@Test class for testing Python Fire with a property with varargs.c                 G   s6   d }g }|D ]$}|d kr|}n||7 }| | q|S r   )append)r   itemstotalZsumsitemr	   r	   r   cumsums   s    zVarArgs.cumsumsr   c                 G   s   ||d |fS )N join)r   r9   r:   charsr	   r	   r   varchars   s    zVarArgs.varcharsN)r   r   )r   r   r   r'   rU   rZ   r	   r	   r	   r   rP      s   rP   c                   @   s   e Zd Zdd Zdd ZdS )Underscoresc                 C   s
   d| _ d S )Nzfish fingers)Zunderscore_exampler   r	   r	   r   r      s    zUnderscores.__init__c                 C   s   |S r   r	   )r   Zunderscore_argr	   r	   r   underscore_function   s    zUnderscores.underscore_functionN)r   r   r   r   r\   r	   r	   r	   r   r[      s   r[   c                   @   s   e Zd ZdddZdS )BoolConverterFc                 C   s   t |S r   )bool)r   argr	   r	   r   as_bool   s    zBoolConverter.as_boolN)F)r   r   r   r`   r	   r	   r	   r   r]      s   r]   c                   @   s   e Zd Zdd ZdS )
ReturnsObjc                 G   s   ~t  S r   )r]   )r   rR   r	   r	   r   get_obj   s    zReturnsObj.get_objN)r   r   r   rb   r	   r	   r	   r   ra      s   ra   c                   @   s    e Zd ZdddZd	ddZdS )
NumberDefaults      $@c                 C   s   d| S NrA   r	   r   Zdivisorr	   r	   r   
reciprocal   s    zNumberDefaults.reciprocalr   c                 C   s   d| S re   r	   rf   r	   r	   r   integer_reciprocal   s    z!NumberDefaults.integer_reciprocalN)rd   )r   )r   r   r   rg   rh   r	   r	   r	   r   rc      s   
rc   c                   @   s   e Zd Zdd Zdd ZdS )InstanceVarsc                 C   s   || _ || _d S r   r
   r   r   r
   r   r	   r	   r   r      s    zInstanceVars.__init__c                 C   s   | j | j||fS r   rj   rk   r	   r	   r   run   s    zInstanceVars.runN)r   r   r   r   rl   r	   r	   r	   r   ri      s   ri   c                   @   s&   e Zd Zdd Zdd ZdddZdS )	Kwargsc                 K   s   |S r   r	   r   kwargsr	   r	   r   props   s    zKwargs.propsc                 K   s   d t|  S )N )rX   sortedkeysupperrn   r	   r	   r   rt      s    zKwargs.upperNc                 K   s
   |||fS r   r	   )r   
positionalnamedro   r	   r	   r   rl      s    z
Kwargs.run)N)r   r   r   rp   rt   rl   r	   r	   r	   r   rm      s   rm   c                   @   s   e Zd Zdd ZdS )ErrorRaiserc                 C   s   t dd S )NzThis error is part of a test.r"   r   r	   r	   r   fail   s    zErrorRaiser.failN)r   r   r   ry   r	   r	   r	   r   rw      s   rw   c                   @   s   e Zd Zdd Zdd ZdS )NonComparablec                 C   s   t dd S Nz+Instances of this class cannot be compared.rx   r   otherr	   r	   r   __eq__  s    zNonComparable.__eq__c                 C   s   t dd S r{   rx   r|   r	   r	   r   __ne__	  s    zNonComparable.__ne__N)r   r   r   r~   r   r	   r	   r	   r   rz     s   rz   c                   @   s   e Zd Zdd Zdd ZdS )EmptyDictOutputc                 C   s   i S r   r	   r   r	   r	   r   totally_empty  s    zEmptyDictOutput.totally_emptyc                 C   s   ddiS )NZ__do_not_print_merI   r	   r   r	   r	   r   nothing_printable  s    z!EmptyDictOutput.nothing_printableN)r   r   r   r   r   r	   r	   r	   r   r     s   r   c                   @   s   e Zd Zdd ZdS )CircularReferencec                 C   s   i }||d< |S )Nyr	   r   xr	   r	   r   create  s    zCircularReference.createN)r   r   r   r   r	   r	   r	   r   r     s   r   c                   @   s   e Zd Zdd Zdd ZdS )OrderedDictionaryc                 C   s   t  S r   collectionsOrderedDictr   r	   r	   r   empty   s    zOrderedDictionary.emptyc                 C   s   t  }d|d< d|d< |S )NAr   r   )r   Zordered_dictr	   r	   r   	non_empty#  s    zOrderedDictionary.non_emptyN)r   r   r   r   r   r	   r	   r	   r   r     s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )
NamedTuplez2Functions returning named tuples used for testing.c                 C   s   t dddg}|dddS )z(Point example straight from Python docs.Pointr   r         )r   r   
namedtupler   r   r	   r	   r   point-  s    zNamedTuple.pointc                 C   s   t dddg}|dddS )zField name equals value.r   r   r   r   r   r   r   r	   r	   r   matching_names3  s    zNamedTuple.matching_namesN)r   r   r   r'   r   r   r	   r	   r	   r   r   *  s   r   c                   @   s$   e Zd ZdZdZdd Zdd ZdS )CallableWithPositionalArgs#Test class for supporting callable.rI   c                 C   s   || S r   r	   )r   r   r   r	   r	   r   __call__?  s    z#CallableWithPositionalArgs.__call__c                 C   s   |d S NrI   r	   r   r	   r	   r   fnB  s    zCallableWithPositionalArgs.fnN)r   r   r   r'   ZTESTr   r   r	   r	   r	   r   r   :  s   r   NamedTuplePointr   r   c                   @   s   e Zd ZdZdd ZdS )SubPointz@Used for verifying subclasses of namedtuples behave as intended.c                 C   s   | j | j S r   r   r   r	   r	   r   coordinate_sumL  s    zSubPoint.coordinate_sumN)r   r   r   r'   r   r	   r	   r	   r   r   I  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )CallableWithKeywordArgumentr   c                 K   s&   |  D ]\}}td||f  qd S )Nz%s: %s)rR   print)r   ro   keyr!   r	   r	   r   r   S  s    z$CallableWithKeywordArgument.__call__c                 C   s   t | d S r   r   r   msgr	   r	   r   	print_msgW  s    z%CallableWithKeywordArgument.print_msgN)r   r   r   r'   r   r   r	   r	   r	   r   r   P  s   r   c                   @   s$   e Zd ZdZdddZd	ddZdS )
ClassWithDocstringzbTest class for testing help text output.

  This is some detail description of this test class.
  Hello!c                 C   s
   || _ dS )zConstructor of the test class.

    Constructs a new ClassWithDocstring object.

    Args:
      message: The default message to print.
    N)message)r   r   r	   r	   r   r   d  s    zClassWithDocstring.__init__Nc                 C   s   |dkr| j }t| dS )zPrints a message.N)r   r   r   r	   r	   r   r   n  s    zClassWithDocstring.print_msg)r   )N)r   r   r   r'   r   r   r	   r	   r	   r   r   ^  s   

r   c                   @   s   e Zd ZdZedd ZdS )ClassWithMultilineDocstringzTest class for testing help text output with multiline docstring.

  This is a test class that has a long docstring description that spans across
  multiple lines for testing line breaking in help text.
  c                 c   s   t | D ]
}|V  qdS )a  Generators have a ``Yields`` section instead of a ``Returns`` section.

    Args:
        n (int): The upper limit of the range to generate, from 0 to `n` - 1.

    Yields:
        int: The next number in the range of 0 to `n` - 1.

    Examples:
        Examples should be written in doctest format, and should illustrate how
        to use the function.

        >>> print([i for i in example_generator(4)])
        [0, 1, 2, 3]

    N)range)nir	   r	   r   example_generator|  s    z-ClassWithMultilineDocstring.example_generatorN)r   r   r   r'   staticmethodr   r	   r	   r	   r   r   u  s   r   c                   C   s
   dddhS NrI   r   Zthreer	   r	   r	   r	   r   
simple_set  s    r   c                   C   s   t dddhS r   )	frozensetr	   r	   r	   r   simple_frozenset  s    r   c                   @   s   e Zd ZdZdS )Subdictz)A subclass of dict, for testing purposes.N)r   r   r   r'   r	   r	   r	   r   r     s   r   Zblue)rI   Zredc                   @   s   e Zd ZdZdZdZdS )ColorrI   r   r.   N)r   r   r   REDGREENBLUEr	   r	   r	   r   r     s   r   c                   @   s4   e Zd ZdZdZdd Zedd Zedd Z	d	S )
HasStaticAndClassMethodsz0A class with a static method and a class method.rI   c                 C   s
   || _ d S r   )instance_state)r   r   r	   r	   r   r     s    z!HasStaticAndClassMethods.__init__c                 C   s   | S r   r	   )argsr	   r	   r   	static_fn  s    z"HasStaticAndClassMethods.static_fnc                 C   s
   || j  S r   )CLASS_STATE)clsr   r	   r	   r   class_fn  s    z!HasStaticAndClassMethods.class_fnN)
r   r   r   r'   r   r   r   r   classmethodr   r	   r	   r	   r   r     s   
r   rI   c                 G   s
   ~ ~~|S )zFunction with varargs.

  Args:
    arg1: Position arg docstring.
    arg2: Position arg docstring.
    arg3: Flags docstring.
    *varargs: Accepts unlimited positional args.
  Returns:
    The unlimited positional args.
  r	   )r
   r   r   varargsr	   r	   r   function_with_varargs  s    r   r.   c                 K   s
   ~| |fS r   r	   r
   r   ro   r	   r	   r   function_with_keyword_arguments  s    r   c                   C   s   dS )zThis has code in the docstring.



  Example:
    x = fn_with_code_in_docstring()
    indentation_matters = True



  Returns:
    True.
  Tr	   r	   r	   r	   r   fn_with_code_in_docstring  s    r   c                   @   sJ   e Zd ZdZdddZdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )BinaryCanvasz:A canvas with which to make binary art, one bit at a time.r   c                    s.    fddt  D | _ | _d| _d| _d S )Nc                    s   g | ]}d g  qS )r   r	   ).0_sizer	   r   
<listcomp>  s     z)BinaryCanvas.__init__.<locals>.<listcomp>r   )r   pixels_size_row_col)r   r   r	   r   r   r     s    zBinaryCanvas.__init__c                 C   s   d dd | jD S )N
c                 s   s"   | ]}d  dd |D V  qdS )rq   c                 s   s   | ]}t |V  qd S r   )str)r   Zpixelr	   r	   r   	<genexpr>  s     z1BinaryCanvas.__str__.<locals>.<genexpr>.<genexpr>NrW   )r   rowr	   r	   r   r     s    z'BinaryCanvas.__str__.<locals>.<genexpr>)rX   r   r   r	   r	   r   __str__  s    
zBinaryCanvas.__str__c                 C   s   t |  | S r   r   r   r	   r	   r   show  s    zBinaryCanvas.showc                 C   s   || j  | _|| j  | _| S r   )r   r   r   )r   r   colr	   r	   r   move  s    zBinaryCanvas.movec                 C   s
   |  dS r   setr   r	   r	   r   on  s    zBinaryCanvas.onc                 C   s
   |  dS )Nr   r   r   r	   r	   r   off  s    zBinaryCanvas.offc                 C   s   || j | j | j< | S r   )r   r   r   r#   r	   r	   r   r     s    zBinaryCanvas.setN)r   )r   r   r   r'   r   r   r   r   r   r   r   r	   r	   r	   r   r     s   
r   c                   @   s   e Zd Zdd Zdd ZdS )DefaultMethodc                 C   s   d| S r)   r	   r   numberr	   r	   r   r,     s    zDefaultMethod.doublec                 C   s   dd }|S )Nc                   S   s   dS )NzUndefined functionr	   r	   r	   r	   r   _missing  s    z+DefaultMethod.__getattr__.<locals>._missingr	   )r   namer   r	   r	   r   __getattr__  s    zDefaultMethod.__getattr__N)r   r   r   r,   r   r	   r	   r	   r   r     s   r   c                   @   s    e Zd Zdd Zedd ZdS )InvalidPropertyc                 C   s   d| S r)   r	   r   r	   r	   r   r,     s    zInvalidProperty.doublec                 C   s   t dd S )Ntestrx   r   r	   r	   r   prop  s    zInvalidProperty.propN)r   r   r   r,   propertyr   r	   r	   r	   r   r   
  s   r   c                    s   t   fdd}|S )Nc                     s
    | |S r   r	   )r   ro   fr	   r   wrapper  s    z!simple_decorator.<locals>.wrapper)	functoolswraps)r   r   r	   r   r   simple_decorator  s    r   Worldc                 C   s   d|  S )NzHello %sr	   )r   r	   r	   r   decorated_method  s    r   c                 K   s   ~ ~| dS )zFunction with kwarg.

  :param arg1: Description of arg1.
  :param arg2: Description of arg2.
  :key arg3: Description of arg3.
  r   getr   r	   r	   r   fn_with_kwarg!  s    r   c                 K   s   ~ ~~| dS )zFunction with kwarg and defaults.

  :param arg1: Description of arg1.
  :param arg2: Description of arg2.
  :key arg3: Description of arg3.
  r   r   )r
   r   optro   r	   r	   r   fn_with_kwarg_and_defaults,  s    r   firstlastlatec                 C   s   ~~| S )zFunction with kwarg and defaults.

  :key first: Description of first.
  :key last: Description of last.
  :key late: Description of late.
  r	   )r   r   r   r	   r	   r   fn_with_multiple_defaults7  s    r   )r   r   )r   )T)rI   )r.   )r   )T)r   r   r   )Hr'   
__future__r   r   r   r   enumr   sixPY3Zfirer   Zpy3r   intrG   r   r   objectr   r   r   r    r$   r(   r1   r5   r6   r=   r@   rE   rH   rP   r[   r]   ra   rc   ri   rm   rw   rz   r   r   r   r   r   r   r   r   r   ZCALLABLE_WITH_KEYWORD_ARGUMENTr   r   r   r   dictr   ZSUBDICTEnumr   r   r   r   r   r   r   r   r   r   r   r   r   r	   r	   r	   r   <module>   s   


					
		

!

