
    h&                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJr  SSK	J
r
JrJrJr  SSKJrJr   " S S\5      r\r " S	 S
5      r " S S\\\
4   5      rSrSr " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S S \5      r! " S! S"\5      r" " S# S$5      r#S)S% jr$S*S& jr%S' r&S(\&l'        g)+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                      \ rS rSrSrg)
UsageError    N)__name__
__module____qualname____firstlineno____static_attributes__r       [/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/usage.pyr   r      s    r   r   c                  $    \ rS rSrSrS rS rSrg)CoerceParameter%   z=
Utility class that can corce a parameter before storing it.
c                T    Xl         X l        [        U R                  SS5      U l        g)zY
@param options: parent Options object
@param coerce: callable used to coerce the value.
	coerceDoc N)optionscoercegetattrdoc)selfr   r   s      r   __init__CoerceParameter.__init__*   s"    
 4;;R8r   c                    Uc  [        SU S35      e U R                  U5      nX R                  R                  U'   g! [         a  n[        SU 35      eSnAff = f)zR
When called in dispatch, do the coerce for C{value} and save the
returned value.
NzParameter 'z' requires an argument.z#Parameter type enforcement failed: )r   r   
ValueErrorr   opts)r    parameterNamevaluees       r   dispatchCoerceParameter.dispatch3   sm    
 ={=/9PQRR	HKK&E ,1-(  	HB1#FGG	Hs   > 
AAA)r   r   r   N)r   r   r   r   __doc__r!   r)   r   r   r   r   r   r   %   s    91r   r   c                     ^  \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   Sr	\
R                  rU 4S	 jr\R                  rS
 rS rSS jrS rS rSS jrS rS rS rSS jrSS jrSSS jjrSrU =r$ )OptionsB   a%  
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	U ]  5         X l        0 U l        / U l        SU l        0 U l        0 U l        0 U l        U R                  U R                  U R                  /nU H  nU" 5       u  p4pVpxU R                  R                  U5        U R
                  U-   U l        U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        M     g )Nr   )superr!   r%   defaultslongOptshortOptdocssynonyms	_dispatch_gather_flags_gather_parameters_gather_handlersextendupdate)
r    
collectorscr6   r7   r8   settingsr9   r)   	__class__s
            r   r!   Options.__init__   s    	 	 ##!!

 AFGcCWLL( MMH4DMIIT"IIX&MM  *MM  *NN!!(+ r   c                b    [        U R                  5       5        [        R                  " S5        g)z
Display this help and exit.
r   N)print__str__sysexitr    s    r   opt_helpOptions.opt_help   s     	dllnr   c                h    SSK Jn  [        SUR                  5        [        R
                  " S5        g)z#
Display Twisted version and exit.
r   )	copyrightzTwisted version:N)twistedrN   rF   versionrH   rI   )r    rN   s     r   opt_versionOptions.opt_version   s#     	& )"3"34r   c                8   Uc  [         R                  SS n[        U5      S:  ah  US   S:X  a_  SSKJn  [
        R                  " [         R                  S   5      nUR                  XXR                  5        [         R                  " S5         [        R                  " XR                  U R                  5      u  pEU H  u  pxUS   S:X  a  USS nOUSS nUn	XR                   ;  a0  UR#                  SS	5      n	XR                   ;  a  [        S
U S35      eU R                   U	   n	[%        U R&                  U	   [(        5      (       a   U R&                  U	   R+                  X5        M  U R&                  U	   " X5        M     [-        U SS5      (       a  U(       d  U R.                  b  U(       d  U R.                  /nUS   USS pU R0                   HO  u  ppX:X  d  X:X  d  M  Xl        U" 5       U l        X R4                  l        U R4                  R9                  U5          O    [        SU
-  5      e U R:                  " U6   U R?                  5         g! [        R                   a  n[        [        U5      5      eSnAff = f! [<         a    [        S5      ef = f)z&
The guts of the command-line parser.
N   z--_shell-completionr   )
_shellcomp-   _zNo such option ''subCommandszUnknown command: %szWrong number of arguments.) rH   argvlentwisted.pythonrV   r   basenameshellComplete_shellCompFilerI   getoptr7   r6   errorr   strr9   replace
isinstancer:   r   r)   r   r1   r[   r0   
subOptionsr2   parseOptions	parseArgs	TypeErrorpostOptions)r    r   rV   cmdNamer%   argsr(   optarg
optMangledsubrestcmdshortparserr   s                   r   rh   Options.parseOptions   sE   
 ?hhqrlG w<!/D D1mmCHHQK0G$$TG=P=PQHHQK	%wt||LJD HC1v}!"g!"gJ. [[c2
]]2$'7uA%>??z2J$..4oFFz*33JDz*:;! $ 4--D**6../Qab+/+;+;'F:&)O&,hDO-1OO*OO006 ,< !!6!<==?% 	U || 	%SV$$	%N  ? !=>>?s$   -I 3J J 'I;;J Jc                    g)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.
Nr   rJ   s    r   rk   Options.postOptions      r   c                    g)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!
Nr   rJ   s    r   ri   Options.parseArgs"  ry   r   c                V    US;  a  [        SU< SU< S35      eSU R                  U'   g )N)r   NzFlag 'z' takes no argument. Not even "z".rT   )r   r%   )r    flagNamer'   s      r   _generic_flagOptions._generic_flag1  s/    
"DLeT   		(r   c                J   / Sp!0 0 0 0 4u  p4pV/ n[         R                  " U R                  SU5        U Hi  n[        R                  " SU5      u  pnU	(       d  [        S5      eXU	'   SXI'   U
(       a  X*-   nXU
'   UR                  U	5        XU	'   U R                  Xi'   Mk     XX4XV4$ )z#
Gather up boolean (flag) options.
r   optFlags   z A flag cannot be without a name.r   )r	   accumulateClassListrC   r
   padTor$   appendr~   )r    r6   r7   r8   rB   r9   r)   flagsflaglongrt   r   s               r   r;   Options._gather_flags9  s    
 -/R^*##DNNJFD#zz!T2D !CDDJHN#+"&NN4 !TN!//HN  $(DDr   c                   / Sp!0 0 0 0 4u  p4pV/ n[         R                  " U R                  SU5        0 nU H  n[        R                  " SU5      u  ppnU	(       d  [        S5      eXU	'   XU	'   U
(       a  X*-   S-   nXU
'   UR                  U	S-   5        XU	'   Ub  [        X5      Xi'   Mt  [        U [        5      Xi'   M     XX4XV4$ )z$
Gather options which take a value.
r   optParameters   z%A parameter cannot be without a name.:=)	r	   r   rC   r
   r   r$   r   r   rd   )r    r6   r7   r8   rB   r9   r)   
parameters	parameterr   rt   defaultr   	paramTypes                 r   r<   Options._gather_parametersT  s     -/R^*
##DNNOZP#I37::a3K0Dy !HIIJ$TN#+c1"&NN4#:&!TN$!0!A!0s!; $" $(DDr   c                T   / Sp!0 0 0 0 4u  p4pV0 n[         R                  " U R                  US5        UR                  5        H  n[	        U SU-   5      n	[        X5      (       + n
UR                  SS5      n[	        U	SS5      nU(       a  XU'   OU R                  R                  U5      X;'   XU'   U
(       a  U	4S jnOSU	4S jnXU'   [        U5      S	:X  a  X(-   nU
(       a  US
-   nM  M  U
(       a  US-   nUR                  U5        M     0 nUR                  5        H>  n[	        U SU-   5      n	X;  a  / X'   X   R                  UR                  SS5      5        M@     UR                  5        H1  u  p[        U5      S:  a  M  [        U[        S9nU H  nUXX'   M	     M3     XX4XV4$ )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_rY   rW   r+   Nc                    U" U5      $ Nr   namer'   ms      r   <lambda>*Options._gather_handlers.<locals>.<lambda>  s    1U8r   c                    U" 5       $ r   r   r   s      r   r   r     s    r   rT   r   r   rX   key)r	   addMethodNamesToDictrC   keysr   flagFunctionre   r8   getr]   r   itemsmax)r    r6   r7   r8   rB   r9   r)   dctr   methodtakesArg
prettyNamer   fnreverse_dctnameslongests                    r   r=   Options._gather_handlerst  s    -/R^*$$T^^S&AHHJDT6D=1F'55Hc3/J&)T2C $'Z #'99==#< #-Z 
 +1; )-;#%Z 4yA~#?'#~H  !+c!1Jz*G J HHJDT6D=1F(&(#&&t||C'=>	  )..0MF5zA~%S)G!( 	 1 $(DDr   c                H    U R                  5       S-   U R                  S S9-   $ )N
width)getSynopsisgetUsagerJ   s    r   rG   Options.__str__  s&    !D(4==t=+DDDr   c                   [         R                  " [        R                  S   5      nUR	                  S5      (       aM  SR                  [        R                  R                  [        R                  5      UR                  SS5      5      nU R                  c/  SR                  UU R                  =(       a    S=(       d    S5      nO!SU R                  =(       a    S=(       d    S-  n[        [        [        U S	U5      5      nUR!                  5       nU R                  bY  U R                  R"                  c   eS
R%                  U R                  R'                  5       U R                  R"                  U45      nU$ )zg
Returns a string containing a description of these options and how to
pass them to the executed file.
r   z	.__main__z{} -m {}r   zUsage: {}{}z
 [options]z%sz	[options]synopsis )r	   filenameToModuleNamerH   r\   endswithformatosr   r_   
executablere   r2   r6   r   rd   r   rstripr0   joinr   )r    executableNamer   r   s       r   r   Options.getSynopsis  s$   
 !55chhqkB"";//'..  0&&{B7N
 ;;#**.,52G
 t||;BCGWT:w?@??$;;";;))555xx((*DKK,B,BHMH r   c                   [        U S5      (       a'  [        [        U R                  5      R	                  US9$ U(       d)  [        [        R                  R                  SS5      5      n[        U S5      (       aO  / nU R                   H  u  p4pVUR                  UUUSS S.5        M     [        X!5      nSS	R                  U5      -   nOS	n0 n	U R                  R                  5        H,  u  pUnX:w  a  [        U
5      S
:X  a  XU'   M!  X;  a  S X'   M,  M.     / nU R                    Hq  nUS   S:X  a  SnUS S nOSnUR                  UX   U R"                  U   UU R$                  R                  US 5      U R&                  R                  US 5      S.5        Ms     [)        U SS 5      b  [        [*        U R,                  5      nO%SS Kn[)        USS 5      (       a  UR0                  nOS	nU(       a:  SSR                  [2        R4                  " UU5      5      R7                  5       -   S-   nU(       a   [        X5      nSS	R                  U5      -  nOSnUU-   U-   $ )Nrg   r   COLUMNS80r[   command)r   rt   r   optTyper   z
Commands:
r   rT   r   r   r   )r   rt   r   r   r   r)   longdescr   r+   r   zOptions:
%szOptions: None
)hasattrr   r-   rg   r   intr   environr   r[   r   docMakeChunksr   r9   r   r]   r6   r8   r5   r:   r   rd   r   __main__r+   textwrapwrapstrip)r    r   cmdDictsrs   rt   ru   descchunkscommandslongToShortr   r'   longnameoptDictsrn   r   r   r   ss                      r   r   Options.getUsage  s,    4&&1:::GG

y$78E4''H,0,<,<(F #!&##,#' -= #83F$rwwv6HH----/JCHc#h!m(+H%.,0K) 0 <<C2w#~%#2h OO(-99S>&#}}00d; $ 2 23 =	  $ j$/7C/HxD11#++diih(FGMMOORVVH"83F"''&/2A!A8|h&&r   )	r:   r5   r8   r6   r%   r7   r0   rg   r9   r   )returnrd   )r   zOptional[int]r   rd   )r   r   r   r   r+   r0   __annotations__r1   r2   completionDatarH   stdoutra   r!   object__hash__rK   rQ   rh   rk   ri   r~   r;   r<   r=   rG   r   r   r   __classcell__)rC   s   @r   r-   r-   B   s    Tl !%J$'+}+"&F&NZZN,D HBH E6E@HETE>K' K'r   r-   zshbashc                  N    \ rS rSr% SrSrS\S'   SS jr\S 5       r	S r
S	 rS
rg)	Completeri2  a9  
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                "    Ub  Xl         X l        g)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      r   r!   Completer.__init__>  s     Kr   c                (    U R                   (       a  gg)N*r   )r   rJ   s    r   _repeatFlagCompleter._repeatFlagO  s    <<r   c                8    U R                   b  U R                   $ U$ r   )r   r    optNames     r   _descriptionCompleter._descriptionV  s    ;;";;Nr   c                v    U[         :X  a!  U R                   SU R                  U5       S3$ [        SU< 35      e)aY  
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r    r   	shellTypes      r   
_shellCodeCompleter._shellCode\  sE     &&'q):):7)C(DAFF!$6ym"DEEr   r   )NF)r   r   r   r   r+   r   r   r!   propertyr   r   r   r   r   r   r   r   r   2  s7     !FM "  Fr   r   c                  .    \ rS rSrSrSS jrS rS rSrg)	CompleteFilesin  z.
Completes file names based on a glob pattern
c                >    [         R                  " U 40 UD6  Xl        g r   )r   r!   _globPattern)r    globPatternkws      r   r!   CompleteFiles.__init__s  s    4&2&'r   c                x    U R                   b  U R                    SU R                   S3$ U SU R                   S3$ )Nz ())r   r  r   s     r   r   CompleteFiles._descriptionw  sD    ;;"kk]"T%6%6$7q99Yb!2!2 3155r   c                    U[         :X  a6  SR                  U R                  U R                  U5      U R                  5      $ [        SU< 35      e)Nz{}:{}:_files -g "{}"r   )r   r   r   r   r  r   r   s      r   r   CompleteFiles._shellCode}  sR    )00  !!'*!! 
 "$6ym"DEEr   )r  N)r   )	r   r   r   r   r+   r!   r   r   r   r   r   r   r   r   n  s    (6Fr   r   c                      \ rS rSrSrS rSrg)CompleteDirsi  z
Completes directory names
c                    U[         :X  a+  SR                  U R                  U R                  U5      5      $ [	        SU< 35      e)Nz{}:{}:_directoriesr   r   r   r   r   r   r   s      r   r   CompleteDirs._shellCode  sH    '..  $"3"3G"<  "$6ym"DEEr   r   Nr   r   r   r   r+   r   r   r   r   r   r  r    s    Fr   r  c                  $    \ rS rSrSrS rS rSrg)CompleteListi  z*
Completes based on a fixed list of words
c                >    [         R                  " U 40 UD6  Xl        g r   r   r!   _itemsr    r   r  s      r   r!   CompleteList.__init__      4&2&r   c                    U[         :X  aE  SR                  U R                  U R                  U5      SR	                  U R
                  5      5      $ [        SU< 35      e)Nz
{}:{}:({})r   r   r   r   r   r   r   r  r   r   s      r   r   CompleteList._shellCode  s\    &&  !!'*KK  "$6ym"DEEr   r  Nr   r   r   r   r+   r!   r   r   r   r   r   r  r    s    	Fr   r  c                  $    \ rS rSrSrS rS rSrg)CompleteMultiListi  zI
Completes multiple comma-separated items based on a fixed list of words
c                >    [         R                  " U 40 UD6  Xl        g r   r  r  s      r   r!   CompleteMultiList.__init__  r  r   c                    U[         :X  aU  SR                  U R                  U R                  U5      U R                  U5      SR	                  U R
                  5      5      $ [        SU< 35      e)Nz{}:{}:_values -s , '{}' {}r   r   r  r   s      r   r   CompleteMultiList._shellCode  sg    /66  !!'*!!'*%	  "$6ym"DEEr   r  Nr  r   r   r   r  r    s    Fr   r  c                      \ rS rSrSrS rSrg)CompleteUsernamesi  z
Complete usernames
c                v    U[         :X  a!  U R                   SU R                  U5       S3$ [        SU< 35      e)Nr   z:_usersr   r   r   s      r   r   CompleteUsernames._shellCode  C    &&'q):):7)C(DGLL!$6ym"DEEr   r   Nr  r   r   r   r%  r%        Fr   r%  c                  "    \ rS rSrSrSrS rSrg)CompleteGroupsi  z
Complete system group names
groupc                v    U[         :X  a!  U R                   SU R                  U5       S3$ [        SU< 35      e)Nr   z:_groupsr   r   r   s      r   r   CompleteGroups._shellCode  sC    &&'q):):7)C(DHMM!$6ym"DEEr   r   Nr   r   r   r   r+   r   r   r   r   r   r   r+  r+    s     FFr   r+  c                      \ rS rSrSrS rSrg)CompleteHostnamesi  z
Complete hostnames
c                v    U[         :X  a!  U R                   SU R                  U5       S3$ [        SU< 35      e)Nr   z:_hostsr   r   r   s      r   r   CompleteHostnames._shellCode  r(  r   r   Nr  r   r   r   r1  r1    r)  r   r1  c                  "    \ rS rSrSrSrS rSrg)CompleteUserAtHosti  z|
A completion action which produces matches in any of these forms::
    <username>
    <hostname>
    <username>@<hostname>
zhost | user@hostc                z    U[         :X  a#  U R                  < SU R                  U5      < S3$ [        SU< 35      e)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      r   r   CompleteUserAtHost._shellCode  sB     $(#3#3T5F5Fw5OQ	 "$6ym"DEEr   r   Nr/  r   r   r   r5  r5    s      FFr   r5  c                      \ rS rSrSrS rSrg)CompleteNetInterfacesi  z"
Complete network interface names
c                    U[         :X  a+  SR                  U R                  U R                  U5      5      $ [	        SU< 35      e)Nz{}:{}:_net_interfacesr   r  r   s      r   r    CompleteNetInterfaces._shellCode   sI    *11  !!'*  "$6ym"DEEr   r   Nr  r   r   r   r9  r9    s    Fr   r9  c                  ,    \ rS rSrSr0 / / 0 / 4S jrSrg)Completionsi	  a6  
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                @    Xl         X l        X0l        X@l        XPl        g r   )descriptionsmultiUsemutuallyExclusive
optActionsextraActions)r    r?  r@  rA  rB  rC  s         r   r!   Completions.__init__]  s      ) !2$(r   )r?  rC  r@  rA  rB  N)r   r   r   r   r+   r!   r   r   r   r   r=  r=  	  s    Qj )r   r=  c                   U R                  S S9  SnU  HM  n[        UR                  SS5      5      nU(       d  M'  UR                  SS5      S:X  a  US	-   n[        XB5      nMO     U[        S
5      -   nX-
  nSU-  n/ n0 n	U  GH_  nUR                  SS5      U	;   d  UR                  SS5      U	;   a  M2  UR                  SS5      UR                  SS5      4 H  n
U
c  M  S	X'   M     / nSnUR                  SS5      (       a
  SUS   4-  nOSnUR                  SS5      (       a0  US   nUR                  SS5      S:X  a  US-   nSX.4-  nU(       a  SnOSU[        S5      -   -  nUR                  SS5      S:X  a  SU-  nOSXU4-  nUR                  SS5      (       a  US   R	                  5       nOSnUR                  SS5      S:X  a(  UR                  SS5      b  SR                  UUS   5      nUR                  SS5      S:X  aP  UR                  SS5       b<  US   n[        U[        5      (       a"  UR                  (       a  U SUR                   3nU(       a  [        R                  " UU5      nOS/nUR                  U UR                  S5       S35        U H  nUR                  U U S35        M     UR                  SR                  U5      5        GMb     U$ )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                X    U R                  SS 5      =(       d    U R                  SS 5      $ )Nrt   r   )r   )os    r   r   docMakeChunks.<locals>.<lambda>{  s"    quuWd3JquuVT7JJr   r   r   r   r   r   Nr   rT   z
  -s, --  r   rt   z-%cr   z%-*s,z--r   z    %s      z  %2s%c --%s  r   r   z{} [default: {}]r)   z. r   )sortr]   r   r   r   r   rf   r   r   r   r   r   popr   )optListr   	maxOptLenrn   optLen	colWidth1	colWidth2
colFiller1	optChunksseenxoptLinescommart   r   column1r   d	column2_llines                       r   r   r   l  s    LLJLKISWWVR()6wwy$';6!F.I  C--I!I
 yJID777D!T)SWWVT-Bd-J$')>>A} ? 777D!!S\O+EE7764  v;Dwwy$';6czY--D)c$i/0D779d#y0$t+G&%)==G775"e*""$CCGGIt$3GGIt$,$++CY@CGGIt$3:
: JA!_--!%%Rw' c95II7)IMM!$4#5R89DOOzl4&34  	*+s v r   c                    [        [        R                  " U 5      R                  5      nUS:  a!  [	        SU=(       d    U R
                  -  5      eUS:X  a  gg)ab  
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}.
rT   zInvalid Option function for %sFT)r]   inspect	signaturer   r   r   )r   r   reqArgss      r   r   r     sM    * '##F+667G{9T=TV__UVV!|r   c                P    [        U 5      n U S:  d  U S:  a  [        SU  35      eU $ )zG
Coerce a string value to an int port number, and checks the validity.
r   i  zPort number not in range: )r   r$   )r'   s    r   
portCoercer`    s2     JEqyEEM5eW=>>Lr   z#Must be an int between 0 and 65535.)P   r   )(r+   
__future__r   rb   r\  r   rH   r   r   typingr   r   r   r   r^   r	   r
   	Exceptionr   rc   r   rd   r-   r   _BASHr   r   r  r  r  r%  r+  r1  r5  r9  r=  r   r   r`  r   r   r   r   <module>rf     s!   #   	 
   , , )	 	 	1 1:i'd38n i'X 9F 9FxFI F2
F9 
FF9 F*F	 F(F	 F
FY 
FF	 FF F6FI F`) `)F_D: =
 r   