%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/usage.cpython-312.pyc

�

Ϫ�f&�����dZddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
ddlmZmZGd�de�ZeZGd	�d
�ZGd�deee
f�Zd
ZdZGd�d�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�d e�Z!Gd!�d"e�Z"Gd#�d$�Z#d)d%�Z$d*d&�Z%d'�Z&d(e&_'y)+a
twisted.python.usage is a module for parsing/handling the
command line of your program.

For information on how to use it, see
U{http://twistedmatrix.com/projects/core/documentation/howto/options.html},
or doc/core/howto/options.xhtml in your Twisted directory.
�)�annotationsN)�path)�Any�Dict�Optional�cast)�reflect�utilc��eZdZy)�
UsageErrorN)�__name__�
__module__�__qualname__���6/usr/lib/python3/dist-packages/twisted/python/usage.pyrrs��rrc��eZdZdZd�Zd�Zy)�CoerceParameterzE
    Utility class that can corce a parameter before storing it.
    c�X�||_||_t|jdd�|_y)zq
        @param options: parent Options object
        @param coerce: callable used to coerce the value.
        �	coerceDoc�N)�options�coerce�getattr�doc)�selfrrs   r�__init__zCoerceParameter.__init__*s&��
�������4�;�;��R�8��rc��|�td|�d���	|j|�}||jj|<y#t$r}td|����d}~wwxYw)zj
        When called in dispatch, do the coerce for C{value} and save the
        returned value.
        NzParameter 'z' requires an argument.z#Parameter type enforcement failed: )rr�
ValueErrorr�opts)r�
parameterName�value�es    r�dispatchzCoerceParameter.dispatch3so��
�=��{�=�/�9P�Q�R�R�	H��K�K��&�E�,1������-�(���	H��B�1�#�F�G�G��	H�s�>�	A�A�AN)r
rr�__doc__rr$rrrrr%s���9�1rrc����eZdZUdZdZded<dZded<dZded<dZe	jZ�fd�Ze
jZd	�Zd
�Zdd�Zd�Zd
�Zdd�Zd�Zd�Zd�Zdd�Zdd�Zddd�Z�xZS)�Optionsa5
    An option list parser class

    C{optFlags} and C{optParameters} are lists of available parameters
    which your program can handle. The difference between the two
    is the 'flags' have an on(1) or off(0) state (off by default)
    whereas 'parameters' have an assigned value, with an optional
    default. (Compare '--verbose' and '--verbosity=2')

    optFlags is assigned a list of lists. Each list represents
    a flag parameter, as so::

       optFlags = [['verbose', 'v', 'Makes it tell you what it doing.'],
                   ['quiet', 'q', 'Be vewy vewy quiet.']]

    As you can see, the first item is the long option name
    (prefixed with '--' on the command line), followed by the
    short option name (prefixed with '-'), and the description.
    The description is used for the built-in handling of the
    --help switch, which prints a usage summary.

    C{optParameters} is much the same, except the list also contains
    a default value::

       optParameters = [['outfile', 'O', 'outfile.log', 'Description...']]

    A coerce function can also be specified as the last element: it will be
    called with the argument and should return the value that will be stored
    for the option. This function can have a C{coerceDoc} attribute which
    will be appended to the documentation of the option.

    subCommands is a list of 4-tuples of (command name, command shortcut,
    parser class, documentation).  If the first non-option argument found is
    one of the given command names, an instance of the given parser class is
    instantiated and given the remainder of the arguments to parse and
    self.opts[command] is set to the command name.  For example::

       subCommands = [
            ['inquisition', 'inquest', InquisitionOptions,
                 'Perform an inquisition'],
            ['holyquest', 'quest', HolyQuestOptions,
                 'Embark upon a holy quest']
        ]

    In this case, C{"<program> holyquest --horseback --for-grail"} will cause
    C{HolyQuestOptions} to be instantiated and asked to parse
    C{['--horseback', '--for-grail']}.  Currently, only the first sub-command
    is parsed, and all options following it are passed to its parser.  If a
    subcommand is found, the subCommand attribute is set to its name and the
    subOptions attribute is set to the Option instance that parses the
    remaining options. If a subcommand is not given to parseOptions,
    the subCommand attribute will be None. You can also mark one of
    the subCommands to be the default::

       defaultSubCommand = 'holyquest'

    In this case, the subCommand attribute will never be None, and
    the subOptions attribute will always be set.

    If you want to handle your own options, define a method named
    C{opt_paramname} that takes C{(self, option)} as arguments. C{option}
    will be whatever immediately follows the parameter on the
    command line. Options fully supports the mapping interface, so you
    can do things like C{'self["option"] = val'} in these methods.

    Shell tab-completion is supported by this class, for zsh only at present.
    Zsh ships with a stub file ("completion function") which, for Twisted
    commands, performs tab-completion on-the-fly using the support provided
    by this class. The stub file lives in our tree at
    C{twisted/python/twisted-completion.zsh}, and in the Zsh tree at
    C{Completion/Unix/Command/_twisted}.

    Tab-completion is based upon the contents of the optFlags and optParameters
    lists. And, optionally, additional metadata may be provided by assigning a
    special attribute, C{compData}, which should be an instance of
    C{Completions}. See that class for details of what can and should be
    included - and see the howto for additional help using these features -
    including how third-parties may take advantage of tab-completion for their
    own commands.

    Advanced functionality is covered in the howto documentation,
    available at
    U{http://twistedmatrix.com/projects/core/documentation/howto/options.html},
    or doc/core/howto/options.xhtml in your Twisted directory.
    N�
Optional[str]�
subCommand�defaultSubCommandz'Optional[Options]'�parentc�`��t�	|��||_i|_g|_d|_i|_i|_i|_|j|j|jg}|D]�}|�\}}}}}}|jj|�|j
|z|_|jj|�|jj|�|jj|�|jj|�|jj|���y)Nr)�superrr �defaults�longOpt�shortOpt�docs�synonyms�	_dispatch�
_gather_flags�_gather_parameters�_gather_handlers�extend�update)
r�
collectors�cr/r0r1�settingsr2r$�	__class__s
         �rrzOptions.__init__�s���
������	���
������
���	���
����
����#�#��!�!�
�
��
	,�A�FG�c�C�W�h��h��(��L�L����(� �M�M�H�4�D�M��I�I���T�"��I�I���X�&��M�M� � ��*��M�M� � ��*��N�N�!�!�(�+�
	,rc�`�t|j��tjd�y)z-
        Display this help and exit.
        rN)�print�__str__�sys�exit�rs r�opt_helpzOptions.opt_help�s��	�d�l�l�n������rc�f�ddlm}td|j�t	j
d�y)z3
        Display Twisted version and exit.
        r)�	copyrightzTwisted version:N)�twistedrEr>�versionr@rA)rrEs  r�opt_versionzOptions.opt_version�s#��	&�
� �)�"3�"3�4�����rc��|�tjdd}t|�dkDrg|ddk(r_ddlm}tjtjd�}|j||||j�tjd�	tj||j|j�\}}|D]�\}}|ddk(r|dd}n|dd}|}	|	|j vr/|j#dd	�}	|	|j vrtd
|�d���|j |	}	t%|j&|	t(�r |j&|	j+|	|���|j&|	|	|���t-|dd�r�|s|j.��|s
|j.g}|d|dd}}
|j0D]R\}}
}}|
|k(s|
|
k(s�||_|�|_||j4_|j4j9|�ntd
|
z��	|j:|�|j?�y#tj$r}tt|���d}~wwxYw#t<$rtd��wxYw)z6
        The guts of the command-line parser.
        N����z--_shell-completionr)�
_shellcomp�-��_zNo such option '�'�subCommandszUnknown command: %szWrong number of arguments.) r@�argv�len�twisted.pythonrLr�basename�
shellComplete�_shellCompFilerA�getoptr0r/�errorr�strr2�replace�
isinstancer3rr$rr*rQr)�
subOptionsr+�parseOptions�	parseArgs�	TypeError�postOptions)rrrL�cmdNamer �argsr#�opt�arg�
optMangled�sub�rest�cmd�short�parserrs                rr^zOptions.parseOptions�sm��
�?��h�h�q�r�l�G��w�<�!�����/D� D�1��m�m�C�H�H�Q�K�0�G��$�$�T�7�G�T�=P�=P�Q��H�H�Q�K�	%����w��
�
�t�|�|�L�J�D�$��	<�H�C���1�v��}��!�"�g���!�"�g���J�����.� �[�[��c�2�
��T�]�]�2�$�'7��u�A�%>�?�?����z�2�J��$�.�.��4�o�F����z�*�3�3�J��D�*����z�*�:�s�;�!	<�$�4���-��D�*�*�6���.�.�/���Q���a�b���C�+/�+;�+;�
>�'��U�F�C��#�:����&)�D�O�&,�h�D�O�-1�D�O�O�*��O�O�0�0��6��

>�!�!6��!<�=�=�
?������%�	
�����U�|�|�	%��S��V�$�$��	%��N�
?� �!=�>�>�
?�s$�.H<�I+�<I(�I#�#I(�+Jc��y)z�
        I am called after the options are parsed.

        Override this method in your subclass to do something after
        the options have been parsed and assigned, like validate that
        all options are sane.
        NrrBs rrazOptions.postOptions��rc��y)a
        I am called with any leftover arguments which were not options.

        Override me to do something with the remaining arguments on
        the command line, those which were not flags or options. e.g.
        interpret them as a list of files to operate on.

        Note that if there more arguments on the command line
        than this method accepts, parseArgs will blow up with
        a getopt.error.  This means if you don't override me,
        parseArgs will blow up if I am passed any arguments at
        all!
        NrrBs rr_zOptions.parseArgs"rmrc�N�|dvrtd|�d|�d���d|j|<y)N)rNzFlag 'z' takes no argument. Not even "z".rJ)rr )r�flagNamer"s   r�
_generic_flagzOptions._generic_flag1s/���
�"��DL�e�T��
� ��	�	�(�rc�H�gd}}iiiif\}}}}g}tj|jd|�|D]d}tjd|�\}	}
}|	std��|||	<d||	<|
r
||
z}|	||
<|j
|	�|	||	<|j||	<�f||||||fS)z3
        Gather up boolean (flag) options.
        r�optFlags�z A flag cannot be without a name.r)r	�accumulateClassListr<r
�padTor�appendrq)rr/r0r1r;r2r$�flags�flag�longrjrs            rr4zOptions._gather_flags9s���
����-/��R��^�*��h��(����#�#�D�N�N�J��F��	0�D�#�z�z�!�T�2��D�%��� �!C�D�D��D��J��H�T�N��#�e�+��"&�����N�N�4� �!�H�T�N�!�/�/�H�T�N�	0���$��(�H�D�Drc��gd}}iiiif\}}}}g}tj|jd|�i}|D]�}tjd|�\}	}
}}}
|	std��|||	<|||	<|
r
||
zdz}|	||
<|j
|	dz�|	||	<|
�t||
�||	<�pt|t�||	<��||||||fS)z4
        Gather options which take a value.
        r�
optParameters�z%A parameter cannot be without a name.�:�=)	r	rur<r
rvrrwrrZ)rr/r0r1r;r2r$�
parameters�	parameterrzrj�defaultr�	paramTypes              rr5zOptions._gather_parametersTs�������-/��R��^�*��h��(��
��#�#�D�N�N�O�Z�P���#�	<�I�37�:�:�a��3K�0�D�%��#�y�� �!H�I�I��D��J�$�H�T�N��#�e�+�c�1��"&�����N�N�4�#�:�&�!�H�T�N��$�!0��y�!A����!0��s�!;����	<�"��$��(�H�D�Drc�(�gd}}iiiif\}}}}i}tj|j|d�|j�D]�}t	|d|z�}	t|	|�}
|j
dd�}t	|	dd�}|r|||<n|jj|�||<|||<|
r|	fd�}
nd|	fd�}
|
||<t|�d	k(r||z}|
s��|d
z}��|
r|dz}|j|���i}|j�D]>}t	|d|z�}	|	|vrg||	<||	j|j
dd���@|j�D]1\}	}t|�dkr�t|t�
�}|D]}|||<�	�3||||||fS)a�
        Gather up options with their own handler methods.

        This returns a tuple of many values.  Amongst those values is a
        synonyms dictionary, mapping all of the possible aliases (C{str})
        for an option to the longest spelling of that option's name
        C({str}).

        Another element is a dispatch dictionary, mapping each user-facing
        option name (with - substituted for _) to a callable to handle that
        option.
        r�opt_rOrMr%Nc��||�S�Nr��namer"�ms   r�<lambda>z*Options._gather_handlers.<locals>.<lambda>�s
��1�U�8�rc��|�Sr�rr�s   rr�z*Options._gather_handlers.<locals>.<lambda>�s����rrJr~rrN��key)
r	�addMethodNamesToDictr<�keysr�flagFunctionr[r1�getrSrw�items�max)rr/r0r1r;r2r$�dctr��method�takesArg�
prettyNamer�fn�reverse_dct�names�longests                 rr6zOptions._gather_handlersts�������-/��R��^�*��h��(����$�$�T�^�^�S�&�A��H�H�J�#	+�D��T�6�D�=�1�F�'���5�5�H����c�3�/�J��&�)�T�2�C��$'��Z� �#'�9�9�=�=��#<��Z� �#-�H�Z� �
�+1�;��)-��;��#%�H�Z� ��4�y�A�~�#�d�?���'�#�~�H��!+�c�!1�J����z�*�G#	+�J���H�H�J�	?�D��T�6�D�=�1�F��[�(�&(��F�#����&�&�t�|�|�C��'=�>�		?�)�.�.�0�	)�M�F�E��5�z�A�~���%�S�)�G��
)��!(����
)�		)���$��(�H�D�Drc�N�|j�dz|jd��zS)N�
��width)�getSynopsis�getUsagerBs rr?zOptions.__str__�s&�����!�D�(�4�=�=�t�=�+D�D�Drc��tjtjd�}|j	d�rMdjtjjtj�|jdd��}|j�%dj||jxrdxsd�}nd|jxrdxsdz}ttt|d	|��}|j!�}|j�X|jj"�J�d
j%|jj'�|jj"|f�}|S)z
        Returns a string containing a description of these options and how to
        pass them to the executed file.
        rz	.__main__z{} -m {}rzUsage: {}{}z
 [options]z%sz	[options]�synopsis� )r	�filenameToModuleNamer@rR�endswith�format�osrrU�
executabler[r+r/rrZr�rstripr)�joinr�)r�executableNamer�r�s    rr�zOptions.getSynopsis�s!��
!�5�5�c�h�h�q�k�B���"�"�;�/�'�.�.���� � ����0��&�&�{�B�7��N�
�;�;��#�*�*�����.�,�5�2��G�
�t�|�|�;��B��C�G���W�T�:�w�?�@���?�?�$���;�;�"��;�;�)�)�5�5�5��x�x����(�(�*�D�K�K�,B�,B�H�M��H��rc�t�t|d�r*tt|j�j	|��S|s)ttjjdd��}t|d�rPg}|jD]\}}}}|j|||ddd��� t||�}dd	j|�z}nd	}i}	|jj�D]*\}
}|}|
|k7rt|
�d
k(r|
|	|<�!||	vrd|	|<�+�,g}
|j D]p}|ddk(rd
}|dd}nd}|
j||	||j"|||j$j|d�|j&j|d�d���rt)|dd��tt*|j,�}n ddl}t)|dd�r
|j0}nd	}|r9ddjt3j4||��j7�zdz}|
r!t|
|�}dd	j|�z}nd}||z|zS)Nr]r��COLUMNS�80rQ�command)rzrjr�optTyper�z
Commands:
rrJ���rr�ry)rzrjrr�r�r$�longdescrr%r�zOptions:
%szOptions: None
)�hasattrrr'r]r��intr��environr�rQrw�
docMakeChunksr�r2r�rSr/r1r.r3rrZr��__main__r%�textwrap�wrap�strip)rr��cmdDictsrirjrk�desc�chunks�commands�longToShortr�r"�longname�optDictsrdr�r�r��ss                   rr�zOptions.getUsage�sF���4��&������1�:�:��:�G�G����
�
���y�$�7�8�E��4��'��H�,0�,<�,<�	
�(��U�F�D���� #�!&�#�#,�#'���	
�#�8�U�3�F�$�r�w�w�v��6�H��H����-�-�-�-�/�	�J�C���H��x��c�#�h�!�m�(+��H�%��;�.�,0�K��)��	����<�<�	�C��2�w�#�~�%���#�2�h�� ���O�O��(��-��9�9�S�>�&�#�}�}�0�0��d�;� $��� 2� 2�3�� =�
�	
�	�$��j�$�/�7��C����/�H���x��D�1�#�+�+������d�i�i��
�
�h��(F�G�M�M�O�O�RV�V�H��"�8�U�3�F��"�'�'�&�/�2�A�!�A��8�|�h�&�&rr�)�returnrZ)r�z
Optional[int]r�rZ)r
rrr%r)�__annotations__r*r+�completionDatar@�stdoutrWr�object�__hash__rCrHr^rar_rqr4r5r6r?r�r��
__classcell__)r<s@rr'r'Bs����T�l!%�J�
�$�'+��}�+�"&�F��&��N��Z�Z�N�,�D���H���B�H�
� �E�6E�@HE�TE��>K'�K'rr'�zsh�bashc�D�eZdZUdZdZded<d	d�Zed��Zd�Z	d�Z
y)
�	CompleteraQ
    A completion "action" - provides completion possibilities for a particular
    command-line option. For example we might provide the user a fixed list of
    choices, or files/dirs according to a glob.

    This class produces no completion matches itself - see the various
    subclasses for specific completion functionality.
    Nr(�_descrc�$�|�||_||_y)a"
        @type descr: C{str}
        @param descr: An optional descriptive string displayed above matches.

        @type repeat: C{bool}
        @param repeat: A flag, defaulting to False, indicating whether this
            C{Completer} should repeat - that is, be used to complete more
            than one command-line word. This may ONLY be set to True for
            actions in the C{extraActions} keyword argument to C{Completions}.
            And ONLY if it is the LAST (or only) action in the C{extraActions}
            list.
        N)r��_repeat)r�descr�repeats   rrzCompleter.__init__>s�����D�K���rc��|jryy)N�*r)r�rBs r�_repeatFlagzCompleter._repeatFlagOs���<�<��rc�6�|j�|jS|Sr�)r��r�optNames  r�_descriptionzCompleter._descriptionVs���;�;�"��;�;���Nrc�r�|tk(r!|j�d|j|��d�Std|����)a�
        Fetch a fragment of shell code representing this action which is
        suitable for use by the completion system in _shellcomp.py

        @type optName: C{str}
        @param optName: The long name of the option this action is being
            used for.

        @type shellType: C{str}
        @param shellType: One of the supported shell constants e.g.
            C{twisted.python.usage._ZSH}
        r~�Unknown shellType ��_ZSHr�r��NotImplementedError�rr��	shellTypes   r�
_shellCodezCompleter._shellCode\sE������&�&�'�q��):�):�7�)C�(D�A�F�F�!�$6�y�m�"D�E�Er)NF)r
rrr%r�r�r�propertyr�r�r�rrrr�r�2s7���!�F�M� ��"�����Frr�c�$�eZdZdZdd�Zd�Zd�Zy)�
CompleteFilesz6
    Completes file names based on a glob pattern
    c�>�tj|fi|��||_yr�)r�r�_globPattern)r�globPattern�kws   rrzCompleteFiles.__init__ss�����4�&�2�&�'��rc�v�|j�|j�d|j�d�S|�d|j�d�S)Nz (�))r�r�r�s  rr�zCompleteFiles._descriptionwsD���;�;�"��k�k�]�"�T�%6�%6�$7�q�9�9��Y�b��!2�!2� 3�1�5�5rc��|tk(r6dj|j|j|�|j�Std|����)Nz{}:{}:_files -g "{}"r�)r�r�r�r�r�r�r�s   rr�zCompleteFiles._shellCode}sR�����)�0�0�� � ��!�!�'�*��!�!��
�
"�$6�y�m�"D�E�ErN)r�)r
rrr%rr�r�rrrr�r�ns���(�6�Frr�c��eZdZdZd�Zy)�CompleteDirsz#
    Completes directory names
    c��|tk(r+dj|j|j|��St	d|����)Nz{}:{}:_directoriesr��r�r�r�r�r�r�s   rr�zCompleteDirs._shellCode�sH�����'�.�.�� � �$�"3�"3�G�"<��
�"�$6�y�m�"D�E�ErN�r
rrr%r�rrrr�r��s
���Frr�c��eZdZdZd�Zd�Zy)�CompleteListz2
    Completes based on a fixed list of words
    c�>�tj|fi|��||_yr��r�r�_items�rr�r�s   rrzCompleteList.__init__�������4�&�2�&���rc��|tk(rEdj|j|j|�dj	|j
��St
d|����)Nz
{}:{}:({})r�r��r�r�r�r�r�r�r�r�s   rr�zCompleteList._shellCode�s\������&�&�� � ��!�!�'�*�����K�K���
�"�$6�y�m�"D�E�ErN�r
rrr%rr�rrrr�r��s����	Frr�c��eZdZdZd�Zd�Zy)�CompleteMultiListzQ
    Completes multiple comma-separated items based on a fixed list of words
    c�>�tj|fi|��||_yr�r�r�s   rrzCompleteMultiList.__init__�r�rc���|tk(rUdj|j|j|�|j|�dj	|j
��St
d|����)Nz{}:{}:_values -s , '{}' {}r�r�r�r�s   rr�zCompleteMultiList._shellCode�sg�����/�6�6�� � ��!�!�'�*��!�!�'�*�������%�	�
�"�$6�y�m�"D�E�ErNr�rrrr�r��s����Frr�c��eZdZdZd�Zy)�CompleteUsernamesz
    Complete usernames
    c�r�|tk(r!|j�d|j|��d�Std|����)Nr~z:_usersr�r�r�s   rr�zCompleteUsernames._shellCode��C������&�&�'�q��):�):�7�)C�(D�G�L�L�!�$6�y�m�"D�E�ErNr�rrrrr��
���Frrc��eZdZdZdZd�Zy)�CompleteGroupsz%
    Complete system group names
    �groupc�r�|tk(r!|j�d|j|��d�Std|����)Nr~z:_groupsr�r�r�s   rr�zCompleteGroups._shellCode�sC������&�&�'�q��):�):�7�)C�(D�H�M�M�!�$6�y�m�"D�E�ErN�r
rrr%r�r�rrrrr�s����F�Frrc��eZdZdZd�Zy)�CompleteHostnamesz
    Complete hostnames
    c�r�|tk(r!|j�d|j|��d�Std|����)Nr~z:_hostsr�r�r�s   rr�zCompleteHostnames._shellCode�rrNr�rrrrr�rrrc��eZdZdZdZd�Zy)�CompleteUserAtHostz�
    A completion action which produces matches in any of these forms::
        <username>
        <hostname>
        <username>@<hostname>
    zhost | user@hostc�r�|tk(r!|j�d|j|��d�Std|����)Nr~aT:{_ssh;if compset -P "*@"; then _wanted hosts expl "remote host name" _ssh_hosts && ret=0 elif compset -S "@*"; then _wanted users expl "login name" _ssh_users -S "" && ret=0 else if (( $+opt_args[-l] )); then tmp=() else tmp=( "users:login name:_ssh_users -qS@" ) fi; _alternative "hosts:remote host name:_ssh_hosts" "$tmp[@]" && ret=0 fi}r�r�r�s   rr�zCompleteUserAtHost._shellCode�sB�����$(�#3�#3�T�5F�5F�w�5O�Q�	
�"�$6�y�m�"D�E�ErNr
rrrrr�s��� �F�Frrc��eZdZdZd�Zy)�CompleteNetInterfacesz*
    Complete network interface names
    c��|tk(r+dj|j|j|��St	d|����)Nz{}:{}:_net_interfacesr�r�r�s   rr�z CompleteNetInterfaces._shellCodesI�����*�1�1�� � ��!�!�'�*��
�"�$6�y�m�"D�E�ErNr�rrrrr�s
���Frrc�"�eZdZdZiggigfd�Zy)�Completionsa:
    Extra metadata for the shell tab-completion system.

    @type descriptions: C{dict}
    @ivar descriptions: ex. C{{"foo" : "use this description for foo instead"}}
        A dict mapping long option names to alternate descriptions.  When this
        variable is defined, the descriptions contained here will override
        those descriptions provided in the optFlags and optParameters
        variables.

    @type multiUse: C{list}
    @ivar multiUse: ex. C{ ["foo", "bar"] }
        An iterable containing those long option names which may appear on the
        command line more than once. By default, options will only be completed
        one time.

    @type mutuallyExclusive: C{list} of C{tuple}
    @ivar mutuallyExclusive: ex. C{ [("foo", "bar"), ("bar", "baz")] }
        A sequence of sequences, with each sub-sequence containing those long
        option names that are mutually exclusive. That is, those options that
        cannot appear on the command line together.

    @type optActions: C{dict}
    @ivar optActions: A dict mapping long option names to shell "actions".
        These actions define what may be completed as the argument to the
        given option. By default, all files/dirs will be completed if no
        action is given. For example::

            {"foo"    : CompleteFiles("*.py", descr="python files"),
             "bar"    : CompleteList(["one", "two", "three"]),
             "colors" : CompleteMultiList(["red", "green", "blue"])}

        Callables may instead be given for the values in this dict. The
        callable should accept no arguments, and return a C{Completer}
        instance used as the action in the same way as the literal actions in
        the example above.

        As you can see in the example above. The "foo" option will have files
        that end in .py completed when the user presses Tab. The "bar"
        option will have either of the strings "one", "two", or "three"
        completed when the user presses Tab.

        "colors" will allow multiple arguments to be completed, separated by
        commas. The possible arguments are red, green, and blue. Examples::

            my_command --foo some-file.foo --colors=red,green
            my_command --colors=green
            my_command --colors=green,blue

        Descriptions for the actions may be given with the optional C{descr}
        keyword argument. This is separate from the description of the option
        itself.

        Normally Zsh does not show these descriptions unless you have
        "verbose" completion turned on. Turn on verbosity with this in your
        ~/.zshrc::

            zstyle ':completion:*' verbose yes
            zstyle ':completion:*:descriptions' format '%B%d%b'

    @type extraActions: C{list}
    @ivar extraActions: Extra arguments are those arguments typically
        appearing at the end of the command-line, which are not associated
        with any particular named option. That is, the arguments that are
        given to the parseArgs() method of your usage.Options subclass. For
        example::
            [CompleteFiles(descr="file to read from"),
             Completer(descr="book title")]

        In the example above, the 1st non-option argument will be described as
        "file to read from" and all file/dir names will be completed (*). The
        2nd non-option argument will be described as "book title", but no
        actual completion matches will be produced.

        See the various C{Completer} subclasses for other types of things which
        may be tab-completed (users, groups, network interfaces, etc).

        Also note the C{repeat=True} flag which may be passed to any of the
        C{Completer} classes. This is set to allow the C{Completer} instance
        to be re-used for subsequent command-line words. See the C{Completer}
        docstring for details.
    c�J�||_||_||_||_||_yr�)�descriptions�multiUse�mutuallyExclusive�
optActions�extraActions)rrrrrrs      rrzCompletions.__init__]s*��)��� ��
�!2���$���(��rN)r
rrr%rrrrrr	s��Q�j�����
)rrc�b�|jd���d}|D]F}t|jdd��}|s�!|jdd�dk(r|d	z}t||�}�H|td
�z}||z
}d|z}g}i}	|D�],}|jdd�|	vs|jdd�|	vr�-|jdd�|jdd�fD]
}
|
��d	|	|
<�g}d}|jdd�r
d
|dfz}
nd}
|jdd�r+|d}|jdd�dk(r|dz}d||fz}|
rd}nd|td�zz}|jdd�dk(rd|z}nd|
||fz}|jdd�r|dj	�}nd}|jdd�dk(r'|jdd��dj||d�}|jdd�dk(rE|jdd�	�2|d}t
|t�r|jr|�d|j��}|rtj||�}ndg}|j|�|jd��d��|D]}|j|�|�d���|jdj|����/|S)a"
    Makes doc chunks for option declarations.

    Takes a list of dictionaries, each of which may have one or more
    of the keys 'long', 'short', 'doc', 'default', 'optType'.

    Returns a list of strings.
    The strings may be multiple lines,
    all of them end with a newline.
    c�N�|jdd�xs|jdd�S)Nrjrz)r�)�os rr�zdocMakeChunks.<locals>.<lambda>{s!��q�u�u�W�d�3�J�q�u�u�V�T�7J�rr�rrzrr�Nr�rJz
  -s, --  r�rjz-%crz%-*s�,z--r�z    %s      z  %2s%c --%s  rr�z{} [default: {}]r$z. r�)�sortrSr�r�r�r�r\rrr�r�rw�popr�)�optListr��	maxOptLenrd�optLen�	colWidth1�	colWidth2�
colFiller1�	optChunks�seen�x�optLines�commarjrz�column1r�d�	column2_l�lines                    rr�r�ls����L�L�J�L�K��I��/���S�W�W�V�R�(�)����w�w�y�$�'�;�6��!����F�I�.�I�
/��C��-�-�I��	�!�I�
�y��J��I�
�D��9,���7�7�7�D�!�T�)�S�W�W�V�T�-B�d�-J������$�'������)>�>�	�A��}���Q��	������7�7�7�D�!��S��\�O�+�E��E��7�7�6�4� ��v�;�D��w�w�y�$�'�;�6��c�z���Y��-�-�D�����)�c�$�i�/�0�D��7�7�9�d�#�y�0�$�t�+�G�&�%���)=�=�G��7�7�5�"���e�*�"�"�$�C��C��G�G�I�t�$��3��G�G�I�t�$�,�$�+�+�C��Y��@�C��G�G�I�t�$��3������:
��:��J��A��!�_�-�!�%�%���R����w�'��� �
�
�c�9�5�I���I����7�)�I�M�M�!�$4�#5�R�8�9��	5�D��O�O�z�l�4�&��3�4�	5�	�������*�+�s9,�v�rc��ttj|�j�}|dkDrt	d|xs|j
z��|dk(ryy)a�
    Determine whether a function is an optional handler for a I{flag} or an
    I{option}.

    A I{flag} handler takes no additional arguments.  It is used to handle
    command-line arguments like I{--nodaemon}.

    An I{option} handler takes one argument.  It is used to handle command-line
    arguments like I{--path=/foo/bar}.

    @param method: The bound method object to inspect.

    @param name: The name of the option for which the function is a handle.
    @type name: L{str}

    @raise UsageError: If the method takes more than one argument.

    @return: If the method is a flag handler, return C{True}.  Otherwise return
        C{False}.
    rJzInvalid Option function for %sFT)rS�inspect�	signaturer�rr
)r�r��reqArgss   rr�r��sM��*�'�#�#�F�+�6�6�7�G���{��9�T�=T�V�_�_�U�V�V��!�|��rc�L�t|�}|dks|dkDrtd|����|S)zO
    Coerce a string value to an int port number, and checks the validity.
    ri��zPort number not in range: )r�r)r"s r�
portCoercer6�s2��
��J�E��q�y�E�E�M��5�e�W�=�>�>��Lrz#Must be an int between 0 and 65535.)�Pr�)(r%�
__future__rrXr2r�r@r�r�typingrrrrrTr	r
�	ExceptionrrYrrZr'r��_BASHr�r�r�r�r�rrrrrrr�r�r6rrrr�<module>r<s!���#�
��	�
���,�,�)�	��	�	��1�1�:i'�d�3��8�n�i'�X
����9F�9F�xF�I�F�2
F�9�
F�F�9�F�*F�	�F�(F�	�F�
F�Y�
F�F�	�F�F��F�6F�I�F�`)�`)�F_�D�:�=�
�r

Zerion Mini Shell 1.0