
    kjQ7                     z   d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZmZmZ ddlZddlmZmZ ddlZddlmZmZ ddlmZmZ ddlmZ dd	lmZmZ dd
lmZmZ  G d d          Z dej        de!fdZ"dej        de
e          fdZ# G d d          Z$edddde%de%dede
e         de!deegef         fd            Z&eddddde%dede
e%         de
e         de!deegef         fd            Z&de%dededeegef         fdZ&	 	 	 d!de%deeegef                  de
e%         de
e         de!deegef         fd Z'dS )"z)
Implements the "option groups" feature.
    )defaultdict)
AnyCallableDictIterableIteratorListOptionalSequenceTupleoverloadN)Option	Parameter)optionmake_arg_metavar)
first_bool	make_repr)
Constraint)HelpSectionensure_is_cloup_formatter)	DecoratorFc            	       t   e Zd Z	 	 	 ddedee         dee         defdZede	e
j                 fd	            Zej        d
ee
j                 ddfd            Zde
j        deeeef                  fdZdededeegef         fdZdee
j                 fdZdede
j        fdZdefdZdefdZdefdZdS )OptionGroupNFtitlehelp
constrainthiddenc                 n    |st          d          || _        || _        g | _        || _        || _        dS )a  Contains the information of an option group and identifies it.
        Note that, as far as the clients of this library are concerned, an
        ``OptionGroups`` acts as a "marker" for options, not as a container for
        related options. When you call ``@optgroup.option(...)`` you are not
        adding an option to a container, you are just adding an option marked
        with this option group.

        .. versionadded:: 0.8.0
            The ``hidden`` parameter.
        zname is a mandatory argumentN)
ValueErrorr   r   _optionsr   r   )selfr   r   r   r   s        O/home/agentuser/manim-venv/lib/python3.11/site-packages/cloup/_option_groups.py__init__zOptionGroup.__init__   sB      	=;<<<
	02$    returnc                     | j         S N)r!   r"   s    r#   optionszOptionGroup.options+   s
    }r%   r*   c                     t          |          x| _        }| j        r|D ]	}d|_        
d S t          d |D                       r	d| _        d S d S )NTc              3   $   K   | ]}|j         V  d S r(   r   .0opts     r#   	<genexpr>z&OptionGroup.options.<locals>.<genexpr>5   s$      ,,,,,,,,r%   )tupler!   r   all)r"   r*   optsr0   s       r#   r*   zOptionGroup.options/   st    $W~~-; 	 " "!

" ",,t,,,,, 	DKKK	 	r%   ctxc                 2    | j         rg S fd| D             S )Nc                 H    g | ]}|j         	|                              S  )r   get_help_record)r/   r0   r5   s     r#   
<listcomp>z0OptionGroup.get_help_records.<locals>.<listcomp>;   s>     
 
 
),CJ
$$
 
 
r%   r-   )r"   r5   s    `r#   get_help_recordszOptionGroup.get_help_records8   s=    ; 	I
 
 
 
04
 
 
 	
r%   param_declsattrsc                     t          |d| i|S )zRefer to :func:`cloup.option`.group)r   )r"   r<   r=   s      r#   r   zOptionGroup.option?   s    {8$8%888r%   c                 *    t          | j                  S r(   )iterr*   r)   s    r#   __iter__zOptionGroup.__iter__C   s    DL!!!r%   ic                     | j         |         S r(   r*   )r"   rC   s     r#   __getitem__zOptionGroup.__getitem__F   s    |Ar%   c                 *    t          | j                  S r(   )lenr*   r)   s    r#   __len__zOptionGroup.__len__I   s    4<   r%   c                 F    t          | | j        | j        | j                  S )N)r   r*   )r   r   r   r*   r)   s    r#   __repr__zOptionGroup.__repr__L   s    tz	4<PPPPr%   c                 N    t          | | j        d | j        D                       S )Nc                     g | ]	}|j         
S r8   )namer.   s     r#   r:   z'OptionGroup.__str__.<locals>.<listcomp>Q   s    &H&H&HCsx&H&H&Hr%   rE   )r   r   r*   r)   s    r#   __str__zOptionGroup.__str__O   s7    $*&H&H4<&H&H&HJ J J 	Jr%   NNF)__name__
__module____qualname__strr
   r   boolr$   propertyr   clickr   r*   setterr   Contextr	   r   r;   r   r   r   r   r   rB   intrF   rI   rK   rO   r8   r%   r#   r   r      s       '+48 % c }%j1    , %,/    X ^x5 $    ^
EM 
d5c?6K 
 
 
 
93 9 91#q&9I 9 9 9 9"(5<0 " " " "S U\    ! ! ! ! !Q# Q Q Q QJ J J J J J Jr%   r   paramr&   c                 (    t          | dd           d uS Nr?   getattrr[   s    r#   has_option_groupra   T   s    5'4((44r%   c                 $    t          | dd           S r]   r^   r`   s    r#   get_option_group_ofrc   X   s    5'4(((r%   c            	           e Zd ZdZdddedee         deddf fdZed	e	e
         dee	ej                 e	e         e	e         f         fd
            Zdej        deej                 fdZdej        dej        deeef         fdZdej        dee         fdZdedej        defdZ	 ddeej                 dedefdZ	 ddej        dedefdZdej        dej        ddfdZ xZS )OptionGroupMixina-  Implements support for:

     - option groups
     - the "Positional arguments" help section; this section is shown only if
       at least one of your arguments has non-empty ``help``.

    .. important::
        In order to check the constraints defined on the option groups,
        a command must inherits from :class:`cloup.ConstraintMixin` too!

    .. versionadded:: 0.14.0
        added the "Positional arguments" help section.

    .. versionchanged:: 0.8.0
        this mixin now relies on ``cloup.HelpFormatter`` to align help sections.
        If a ``click.HelpFormatter`` is used with a ``TypeError`` is raised.

    .. versionchanged:: 0.8.0
        removed ``format_option_group``. Added ``get_default_option_group`` and
        ``make_option_group_help_section``.

    .. versionadded:: 0.5.0
    N)align_option_groupsargsrf   kwargsr&   c                     t                      j        |i | || _        |                    d          pg }|                     |          \  }}}|| _        || _        	 || _        dS )a5  
        :param align_option_groups:
            whether to align the columns of all option groups' help sections.
            This is also available as a context setting having a lower priority
            than this attribute. Given that this setting should be consistent
            across all you commands, you should probably use the context
            setting only.
        :param args:
            positional arguments forwarded to the next class in the MRO
        :param kwargs:
            keyword arguments forwarded to the next class in the MRO
        paramsN)superr$   rf   get_group_params	argumentsoption_groupsungrouped_options)	r"   rf   rg   rh   rj   rn   ro   rp   	__class__s	           r#   r$   zOptionGroupMixin.__init__v   s~     	$)&)))#6 H%%+6:6H6H6P6P3	="3"*K!2	/ 	/r%   rj   c                    t          t                    }g }g }| D ]}t          |t          j                  r|                    |           2t          |t          j                  rBt          |          }||                    |           s||                             |           t          |                                          }|	                                D ]\  }}||_
        |||fS r(   )r   list
isinstancerW   Argumentappendr   rc   keysitemsr*   )	rj   options_by_grouprn   rp   r[   grpro   r?   r*   s	            r#   rm   zOptionGroupMixin._group_params   s    
 CNdBSBS*,	02 	8 	8E%00 8  ''''E5<00 8)%00;%,,U3333$S)00777-224455.4466 	$ 	$NE7#EMM-):::r%   r5   c                 ^    |j                             |          }|| j        |gz   S | j        S )zReturn options not explicitly assigned to an option group
        (eventually including the ``--help`` option), i.e. options that will be
        part of the "default option group".)commandget_help_optionrp   )r"   r5   help_options      r#   get_ungrouped_optionsz&OptionGroupMixin.get_ungrouped_options   s8     k11#66")[M99))r%   argc                     t          |t          j                  r|                    |          S t	          ||          dfS )N )rt   cloupru   r9   r   )r"   r   r5   s      r#   get_argument_help_recordz)OptionGroupMixin.get_argument_help_record   sA     c5>** 	,&&s+++S))2--r%   c                      d  j         D             }t          |          sd S t          d fd j         D                       S )Nc              3   <   K   | ]}t          |d d          |V  dS )r   Nr^   )r/   r   s     r#   r1   z>OptionGroupMixin.get_arguments_help_section.<locals>.<genexpr>   s4      VV#73PT;U;UV#VVVVVVr%   zPositional argumentsc                 <    g | ]}                     |          S r8   )r   )r/   r   r5   r"   s     r#   r:   z?OptionGroupMixin.get_arguments_help_section.<locals>.<listcomp>   s6       <?--c377  r%   )headingdefinitions)rn   anyr   )r"   r5   args_with_helps   `` r#   get_arguments_help_sectionz+OptionGroupMixin.get_arguments_help_section   su    VVVVV>"" 	4*    CG>  
 
 
 	
r%   r?   c                     t          |j        |                    |          |j        |j        r|j                            |          nd          S )zReturn a ``HelpSection`` for an ``OptionGroup``, i.e. an object containing
        the title, the optional description and the options' definitions for
        this option group.

        .. versionadded:: 0.8.0
        N)r   r   r   r   )r   r   r;   r   r   )r"   r?   r5   s      r#   make_option_group_help_sectionz/OptionGroupMixin.make_option_group_help_section   sW     K..s335:5EOu',,S1114	
 
 
 	
r%   Tdefaultc                 L    t          | j        t          |dd          |          S )z
        Return ``True`` if the help sections of all options groups should have
        their columns aligned.

        .. versionadded:: 0.8.0
        rf   N)r   rf   r_   )r"   r5   r   s      r#   must_align_option_groupsz)OptionGroupMixin.must_align_option_groups   s/     $C.55
 
 	
r%   F is_the_only_visible_option_groupc                 `    t          |rdnd          }|                     |          |_        |S )z
        Return an ``OptionGroup`` instance for the options not explicitly
        assigned to an option group, eventually including the ``--help`` option.

        .. versionadded:: 0.8.0
        OptionszOther options)r   r   r*   )r"   r5   r   default_groups       r#   get_default_option_groupz)OptionGroupMixin.get_default_option_group   s=     $9NIIP P $ : :3 ? ?r%   	formatterc                     t          |          }g }                               }|r|                    |            fd j        D             }                     |           }|j        s)|                                         |                     ||z  }|                    |                                          d S )Nc                 J    g | ]}|j         	                    |           S r8   )r   r   )r/   r?   r5   r"   s     r#   r:   z2OptionGroupMixin.format_params.<locals>.<listcomp>  sA     !
 !
 !
<!
//s;;!
 !
 !
r%   )r   )aligned)	r   r   rv   ro   r   r   r   write_many_sectionsr   )r"   r5   r   visible_sectionspositional_arguments_sectionoption_group_sectionsr   s   ``     r#   format_paramszOptionGroupMixin.format_params   s(    .i88	 (,'F'Fs'K'K$' 	B##$@AAA!
 !
 !
 !
 !
+!
 !
 !

 556K2K 6 
 
 # 	I!((33M3GGI I I 	11%%11#66 	& 	
 	
 	
 	
 	
r%   )T)F)rQ   rR   rS   __doc__r   r
   rU   r$   staticmethodr	   r   r   rW   ru   r   r   rm   rY   r   r   rT   r   r   r   r   r   r   HelpFormatterr   __classcell__)rq   s   @r#   re   re   ]   s0        2 AE /  /  / //7~ /PS /	 /  /  /  /  /  /D ;Y;	tEN#T+%6VD	E; ; ; \;.* *8EL;Q * * * *.>.(-.	sCx. . . .	
em 	
@U 	
 	
 	
 	

 
',}
	
 
 
 
" =A
 
EM*
59
	
 
 
 
  LQ =DH	   
=
-2-@
	
 
 
 
 
 
 
 
r%   re   F)r   r   r   r   r*   r   r   c                    d S r(   r8   r   r   r   r   r*   s        r#   option_groupr     	     Cr%   r   r   r   c                    d S r(   r8   r   s        r#   r   r   %  r   r%   rg   rh   c                     |r9t          |d         t                    rt          | f|dd         |d         d|S t          | fd|i|S )a  
    Return a decorator that annotates a function with an option group.

    The ``help`` argument is an optional description and can be provided either
    as keyword argument or as 2nd positional argument after the ``name`` of
    the group::

        # help as keyword argument
        @option_group(name, *options, help=None, ...)

        # help as 2nd positional argument
        @option_group(name, help, *options, ...)

    .. versionchanged:: 0.9.0
        in order to support the decorator :func:`cloup.constrained_params`,
        ``@option_group`` now allows each input decorators to add multiple
        options.

    :param title:
        title of the help section describing the option group.
    :param help:
        an optional description shown below the name; can be provided as keyword
        argument or 2nd positional argument.
    :param options:
        an arbitrary number of decorators like ``click.option``, which attach
        one or multiple options to the decorated command function.
    :param constraint:
        an optional instance of :class:`~cloup.constraints.Constraint`
        (see :doc:`Constraints </pages/constraints>` for more info);
        a description of the constraint will be shown between squared brackets
        aside the option group title (or below it if too long).
    :param hidden:
        if ``True``, the option group and all its options are hidden from the help page
        (all contained options will have their ``hidden`` attribute set to ``True``).
    r      N)r*   r   r*   )rt   rT   _option_group)r   rg   rh   s      r#   r   r   1  sf    H  <
47C(( <UMDH47MMfMMMU;;D;F;;;r%   c                      t           t                    st          d          st          d          dt          dt          f fd}|S )NzYthe first argument of `@option_group` must be its title, a string; you probably forgot itz$you must provide at least one optionfr&   c                    t          	
          }t          | d          sg | _        | j        }t                    D ]}t	          |          } ||            ||d          }|D ]`}t          |t                    st          d          t          |          }|t          d| d| dd          ||_
        
rd|_        a| S )	Nr   __click_params__z=only parameter of type `Option` can be added to option groupszOption "z" was first assigned to group "z0" and then passed as argument to `@option_group(z, ...)`T)r   hasattrr   reversedrH   rt   r   	TypeErrorrc   r    r?   r   )r   	opt_group
cli_params
add_optionprev_lenadded_options
new_optionexisting_groupr   r   r   r*   r   s           r#   	decoratorz _option_group.<locals>.decoratork  s0   DZPVWWW	q,-- 	$!#A'
"7++ 	- 	-J:HJqMMM&xyy1M+ - -
!*f55 Y#WY Y Y!4Z!@!@!-$;: ; ;*; ;*/; ; ;  
 $-
  -(,J%- r%   )rt   rT   r   r    r   )r   r*   r   r   r   r   s   ````` r#   r   r   [  s     eS!! 
%
 
 	

  A?@@@Q 1          2 r%   rP   )(r   collectionsr   typingr   r   r   r   r   r	   r
   r   r   r   rW   r   r   r   cloup._paramsr   r   cloup._utilr   r   cloup.constraintsr   cloup.formattingr   r   cloup.typingr   r   r   rU   ra   rc   re   rT   r   r   r8   r%   r#   <module>r      s    $ # # # # #                         # # # # # # # #  2 2 2 2 2 2 2 2 - - - - - - - - ( ( ( ( ( ( C C C C C C C C % % % % % % % %=J =J =J =J =J =J =J =J@5EO 5 5 5 5 5)u| )0E ) ) ) )
z
 z
 z
 z
 z
 z
 z
 z
z 

 (,  
  $	
  qc1f   
 
 '+   3- $	
  qc1f   
'< '<C '<3 '<8QCF;K '< '< '< '<Z '+) ))hsAv&') 3-) $	)
 ) qc1f) ) ) ) ) )r%   