
    h                          S r SSKrSSKJrJrJr  SSKJrJr  SSK	J
r
  SSKJr   " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      rSrS rS rS r " S S5      rg)z
Support for resolving command-line strings that represent different
checkers available to cred.

Examples:
 - passwd:/etc/passwd
 - memory:admin:asdf:user:lkj
 - unix
    N)OptionalSequenceType)	Attribute	Interface)
getPlugins)usagec                   ^    \ rS rSrSr\" S5      r\" S5      r\" S5      r\" S5      r	S r
Srg	)
ICheckerFactory   z
A factory for objects which provide
L{twisted.cred.checkers.ICredentialsChecker}.

It's implemented by twistd plugins creating checkers.
z0A tag that identifies the authentication method.zmA detailed (potentially multi-line) description of precisely what functionality this CheckerFactory provides.z=A short (one-line) description of the argument string format.z@A list of credentials interfaces that this factory will support.c                     g)ze
Return an L{twisted.cred.checkers.ICredentialsChecker} provider using the supplied
argument string.
N )	argstrings    [/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/cred/strcred.pygenerateCheckerICheckerFactory.generateChecker2   s        r   N)__name__
__module____qualname____firstlineno____doc__r   authTypeauthHelpargStringFormatcredentialInterfacesr   __static_attributes__r   r   r   r   r      sG     KLH	;H
  GO %Jr   r   c                       \ rS rSrSrSrg)StrcredException9   z#
Base exception class for strcred.
r   Nr   r   r   r   r   r   r   r   r   r   r   9   s    r   r   c                       \ rS rSrSrSrg)InvalidAuthType?   zj
Raised when a user provides an invalid identifier for the
authentication plugin (known as the authType).
r   Nr!   r   r   r   r#   r#   ?       r   r#   c                       \ rS rSrSrSrg)InvalidAuthArgumentStringF   z`
Raised by an authentication plugin when the argument string
provided is formatted incorrectly.
r   Nr!   r   r   r   r'   r'   F   r%   r   r'   c                       \ rS rSrSrSrg)UnsupportedInterfacesM   z
Raised when an application is given a checker to use that does not
provide any of the application's supported credentials interfaces.
r   Nr!   r   r   r   r*   r*   M   r%   r   r*   z<WARNING: This authType is not supported by this application.c                       [        [        5      $ )z5
Find all objects that implement L{ICheckerFactory}.
)r   r   r   r   r   findCheckerFactoriesr-   Y   s     o&&r   c                 b    [        5        H  nUR                  U :X  d  M  Us  $    [        U 5      e)zB
Find the first checker factory that supports the given authType.
)r-   r   r#   )r   factorys     r   findCheckerFactoryr0   `   s1     ()x'N * (
##r   c                 t    SU ;   a  U R                  SS5      u  pOU nSn[        U5      R                  U5      $ )z
Returns an L{twisted.cred.checkers.ICredentialsChecker} based on the
contents of a descriptive string. Similar to
L{twisted.application.strports}.
:    )splitr0   r   )descriptionr   r   s      r   makeCheckerr7   j   sC     k)//Q7)	h'77	BBr   c                   |    \ rS rSr% SrSr\\\\	         \
S'   \R                  rS rS rS rS rS	 rS
 rS rSrg)AuthOptionMixinx   a+  
Defines helper methods that can be added on to any
L{usage.Options} subclass that needs authentication.

This mixin implements three new options methods:

The opt_auth method (--auth) will write two new values to the
'self' dictionary: C{credInterfaces} (a dict of lists) and
C{credCheckers} (a list).

The opt_help_auth method (--help-auth) will search for all
available checker plugins and list them for the user; it will exit
when finished.

The opt_help_auth_type method (--help-auth-type) will display
detailed help for a particular checker plugin.

@cvar supportedInterfaces: An iterable object that returns
   credential interfaces which this application is able to support.

@cvar authOutput: A writeable object to which this options class
    will send all help-related output. Default: L{sys.stdout}
NsupportedInterfacesc                 H    U R                   SL =(       d    XR                   ;   $ )zB
Returns whether a particular credentials interface is supported.
N)r;   )self	interfaces     r   supportsInterface!AuthOptionMixin.supportsInterface   s#     ''4/X9@X@X3XXr   c                 Z    UR                    H  nU R                  U5      (       d  M    g   g)zo
Returns whether a checker factory will provide at least one of
the credentials interfaces that we care about.
TF)r   r?   r=   r/   r>   s      r   supportsCheckerFactory&AuthOptionMixin.supportsCheckerFactory   s-    
 !55I%%i00 6 r   c                    / nU R                   c  UR                  nO<UR                   H,  nU R                  U5      (       d  M  UR                  U5        M.     U(       d  [	        UR                  5      eSU ;  a  0 U S'   SU ;  a  / U S'   U S   R                  U5        U H'  nU S   R                  U/ 5      R                  U5        M)     g)z=
Supply a supplied credentials checker to the Options class.
NcredInterfacescredCheckers)r;   r   r?   appendr*   
setdefault)r=   checker	supportedr>   s       r   
addCheckerAuthOptionMixin.addChecker   s    
 	##+44I$99	)))44$$Y/ : '(D(DEE4'%'D!"%#%D ^##G,"I!"--i<CCGL #r   c                 \    U R                  [        U5      5        g! [         a+  n[        R                  " SUR
                  S   -  5      eSnAf[         a+  n[        R                  " SUR
                  S   -  5      eSnAf[         a  n[        R                  " SU-  5      eSnAff = f)z2
Specify an authentication method for the server.
zAuth plugin not supported: %sr   NzAuth plugin not recognized: %szUnexpected error: %s)rL   r7   r*   r	   
UsageErrorargsr#   	Exception)r=   r6   es      r   opt_authAuthOptionMixin.opt_auth   s    	?OOK45$ 	P""#BQVVAY#NOO 	Q""#CaffQi#OPP 	?""#9A#=>>	?s,    
B+&AB+&B  B+B&&B+c              #      #    [        5        H3  nUR                   H   nU R                  U5      (       d  M  Uv     M1     M5     g7f)zt
Return a list of which authTypes will be displayed by --help-auth.
This makes it a lot easier to test this module.
N)r-   r   r?   rB   s      r   _checkerFactoriesForOptHelpAuth/AuthOptionMixin._checkerFactoriesForOptHelpAuth   s=     
 ,-G$99	)))44!M : .s
   1AAc                    U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        SnU R                  5        H3  n[        UR                  5      U:  d  M  [        UR                  5      nM5     SU-  nU R                   R                  US-  5        U R                   R                  US-  5        U R                  5        H6  nU R                   R                  X2R                  UR
                  4-  5        M8     U R                   R                  S5        [        S5      e)z,
Show all authentication methods available.
z#Usage: --auth AuthType[:ArgString]
z-For detailed help: --help-auth-type AuthType

r   z  %%-%is	%%s
)AuthTypezArgString format)z========z================)
authOutputwriterV   lenr   r   
SystemExit)r=   firstLengthr/   formatStrings       r   opt_help_authAuthOptionMixin.opt_help_auth   s    	DENOd#;;=G7##${2!'"2"23 > );6l-MMNl-MMN;;=GOO!! 0 0'2I2IJJ > 	d#mr   c                     [        U5      nU R                  R                  SU-  5        U R                  R                  SUR                  -  5        U R                  R                  S5        UR                  R                  5       R                  5        H/  nU R                  R                  SUR                  5       -  5        M1     U R                  R                  S5        U R                  U5      (       d=  U R                  R                  S[        -  5        U R                  R                  S5        [        S5      e! [         a    [        R                  " SU-  5      ef = f)z1
Show help for a particular authentication type.
zInvalid auth type: %szUsage: --auth %s[:ArgString]
zArgString format: %s
rY   z  %s
r   )r0   r#   r	   rO   r[   r\   r   r   strip
splitlinesrstriprC   notSupportedWarningr^   )r=   r   cflines       r   opt_help_auth_type"AuthOptionMixin.opt_help_auth_type   s   	G#H-B 	>IJ69K9KKLd#KK%%'224DOO!!(T[[]":; 5d#**2..OO!!(-@"@AOO!!$'m  	G""#:X#EFF	Gs   E $E&r   )r   r   r   r   r   r;   r   r   r   r   __annotations__sysstdoutr[   r?   rC   rL   rS   rV   ra   rj   r   r   r   r   r9   r9   x   sR    0 @D(4	?";<CJYM.?	,r   r9   )r   rm   typingr   r   r   zope.interfacer   r   twisted.pluginr   twisted.pythonr	   r   rQ   r   r#   r'   r*   rg   r-   r0   r7   r9   r   r   r   <module>rs      s     + + / %  i <y &  0 ,  X '$CB Br   