
    .Ph                         d Z ddlZddlZddlZddlZddlZddlmZmZ ddl	m
Z
 ddlmZ ej        ej        gef         Z ej        e          Zdadej        ddfd	Zdej        fd
Zd dZdededej        e         fdZdedededdfdZdededdfdZdedej        e         dej        ej                 fdZdefdZ d!dej        e         fdZ!d!dej        e         fdZ"dedej#        ej                 fdZ$dedej        fdZ%dej        ej                 fdZ&d Z'd Z(dej        ej                 fdZ)dej*        ddfdZ+dS )"z1
Core API functions and initialization routines.
    N   )backendcredentials)fail)	platform_keyringreturnc                 \    t          | t          j                  st          d          | adS )zSet current keyring backend.z1The keyring must be an instance of KeyringBackendN)
isinstancer   KeyringBackend	TypeError_keyring_backend)r   s    L/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/keyring/core.pyset_keyringr      s5     gw566 MKLLL    c                  t    t           t                       t          j        t          j        t                     S )zGet current keyring backend.)r   init_backendtypingcastr   r    r   r   get_keyringr      s'    ;w-/?@@@r   c                     t          j                    } 	 t          j        |            n# t          $ r Y nw xY wt          j                            | d          }t          j                            |          rd| }t          |          t          |dd          5 }|
                    d           ddd           dS # 1 swxY w Y   dS )z
    Configure the null keyring as the default.

    >>> fs = getfixture('fs')
    >>> disable()
    >>> disable()
    Traceback (most recent call last):
    ...
    RuntimeError: Refusing to overwrite...
    keyringrc.cfgzRefusing to overwrite wutf-8encodingz7[backend]
default-keyring=keyring.backends.null.KeyringN)platformconfig_rootosmakedirsOSErrorpathjoinexistsRuntimeErroropenwrite)rootfilenamemsgfiles       r   disabler-   %   s,    !!D
D   w||D/22H	w~~h  1x113	hg	.	.	. O$

MNNNO O O O O O O O O O O O O O O O O Os   * 
77CC	Cservice_nameusernamec                 F    t                                          | |          S )z(Get password from the specified service.)r   get_passwordr.   r/   s     r   r1   r1   =   s    ==%%lH===r   passwordc                 L    t                                          | ||           dS )z3Set password for the user in the specified service.N)r   set_password)r.   r/   r3   s      r   r5   r5   B   s$    MM|Xx@@@@@r   c                 J    t                                          | |           dS )z:Delete the password for the user in the specified service.N)r   delete_passwordr2   s     r   r7   r7   G   s"    MM!!,99999r   c                 F    t                                          | |          S )z+Get a Credential for the specified service.)r   get_credentialr2   s     r   r9   r9   L   s     ==''h???r   c                     | j         dk    S )Nr   )priority)r   s    r   recommendedr<   S   s    q  r   limitc                 >    t          t          |                      dS )z"
    Load a detected backend.
    N)r   _detect_backendr=   s    r   r   r   W   s      &&'''''r   c                     | t           _        t                      pYt                      pKt	          t          | t          j                              t          j                    t           j	                  S )z
    Return a keyring specified in the config file or infer the best available.

    Limit, if supplied, should be a callable taking a backend and returning
    True if that backend should be included for consideration.
    )defaultkey)
r   _limitload_envload_configmaxfilterget_all_keyringr   Keyringby_priorityr@   s    r   r?   r?   ^   s_     GN

 	
==	
5'13344LNN#	
 
 
	r   keyring_namec                     |                      d          \  }}}t          |           t          j        |         }t	          ||          S )a  
    Load the keyring class indicated by name.

    These popular names are tested to ensure their presence.

    >>> popular_names = [
    ...      'keyring.backends.Windows.WinVaultKeyring',
    ...      'keyring.backends.macOS.Keyring',
    ...      'keyring.backends.kwallet.DBusKeyring',
    ...      'keyring.backends.SecretService.Keyring',
    ...  ]
    >>> list(map(_load_keyring_class, popular_names))
    [...]
    .)
rpartition
__import__sysmodulesgetattr)rL   module_namesep
class_namemodules        r   _load_keyring_classrX   t   sH     $0#:#:3#?#? Kj{[%F6:&&&r   c                 B    t          |           }|j          |            S )z
    Load the specified keyring by name (a fully-qualified name to the
    keyring, such as 'keyring.backends.file.PlaintextKeyring')
    )rX   r;   )rL   class_s     r   load_keyringr[      s#    
 !..F
OO688Or   c                  d    	 t          t          j        d                   S # t          $ r Y dS w xY w)z6Load a keyring configured in the environment variable.PYTHON_KEYRING_BACKENDN)r[   r    environKeyErrorr   r   r   rE   rE      s?    BJ'?@AAA   tts   ! 
//c                  .    t          j                    dz  S )Nr   )r   r   r   r   r   _config_pathra      s    !!O33r   c                 L    |                                  st          |           | S N)r%   FileNotFoundError)r#   s    r   _ensure_pathre      s%    ;;== &%%%Kr   c                     t          j                    } 	 |                     t          t	                                d           n# t
          $ r Y dS w xY wt          |            	 |                     d          r)|                     dd          	                                }ndS nX# t           j
        t          f$ r? t          j        d          }|                    ddt	                       z              Y dS w xY wt          |          S )	z8Load a keyring using the config file in the config root.r   r   Nr   zdefault-keyringr   z/Keyring config file contains incorrect values.
zConfig file: )configparserRawConfigParserreadre   ra   rd   _load_keyring_pathhas_sectiongetstripNoOptionErrorImportErrorlogging	getLoggerwarningr[   )configrL   loggers      r   rF   rF      s.    )++FL007CCCC   ttvi(( 	!::i1BCCIIKKLL4  &4   "9-->.lnn../	
 	
 	
 tt %%%s$   0A 
AA'>B( (AC=<C=rs   c                    	 |                      dd                                          }t          j                            dt
          j                            |                     dS # t          j        t          j	        f$ r Y dS w xY w)z)load the keyring-path option (if present)r   zkeyring-pathr   N)
rl   rm   rQ   r#   insertr    
expanduserrg   rn   NoSectionError)rs   r#   s     r   rj   rj      s    zz)^44::<<27--d3344444&(CD   s   A%A) )BB)r	   Nrc   ),__doc__rg   rp   r    rQ   r    r   r   backendsr   utilr   r   Callabler   boolLimitCallablerq   __name__logr   r   r   r-   strOptionalr1   r5   r7   
Credentialr9   r<   r   r?   TyperX   r[   rE   ra   re   rF   rh   rj   r   r   r   <module>r      s2         				 



  " " " " " " " "       ' ' ' ' ' '!7 8$ >?g!! / D    AW+ A A A AO O O O0>s >c >foc6J > > > >
As Ac AS AT A A A A
:# : : : : : :
@@!'!5@_[+,@ @ @ @!D ! ! ! !( (6 ( ( ( ( 6?=9    ,'c 'fk':P.Q ' ' ' '*s w'=    &/'"89    4 4 4  &V_W%;< & & & &8|;       r   