HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/keyring/__pycache__/backend.cpython-38.pyc
U

ۦ�\��@s�dZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
ddl
mZddlm
Z
mZeZe�e�Ze�d�ZdZGd	d
�d
ej�Ze
e�Gdd�d��ZGd
d�d�ZGdd�de�Zdd�Ze
jdd��ZdS)z 
Keyring implementation support
�)�absolute_importN�)�credentials�errors�util)�
properties)�
add_metaclass�filter�prioritycs eZdZdZ�fdd�Z�ZS)�KeyringBackendMetazn
    A metaclass that's both an ABCMeta and a type that keeps a registry of
    all (non-abstract) types.
    cs@tt|��|||�t|d�s&t�|_|j}|js<|�|�dS)N�_classes)�superr�__init__�hasattr�setr�__abstractmethods__�add)�cls�name�bases�dict�classes��	__class__��1/usr/lib/python3/dist-packages/keyring/backend.pyrs
zKeyringBackendMeta.__init__)�__name__�
__module__�__qualname__�__doc__r�
__classcell__rrrrrsrc@s|eZdZdZdd�Zejedd���Zedd��Z	ejedd	���Z
d
d�Zej
dd
��Zej
dd��Zdd�Zdd�ZdS)�KeyringBackendz]The abstract base class of the keyring, every backend must implement
    this interface.
    cCsdS)a�
        Each backend class must supply a priority, a number (float or integer)
        indicating the priority of the backend relative to all other backends.
        The priority need not be static -- it may (and should) vary based
        attributes of the environment in which is runs (platform, available
        packages, etc.).

        A higher number indicates a higher priority. The priority should raise
        a RuntimeError with a message indicating the underlying cause if the
        backend is not suitable for the current environment.

        As a rule of thumb, a priority between zero but less than one is
        suitable, but a priority of one or greater is recommended.
        Nr�rrrrr
/szKeyringBackend.priorityc	Cs$t���}|jW5QRXt|�S�N)rZExceptionRaisedContextr
�bool)r�excrrr�viable?s
zKeyringBackend.viablecCstt�d�|j�S)z6
        Return all subclasses deemed viable.
        r&)r	�operator�
attrgetterrr"rrr�get_viable_backendsFsz"KeyringBackend.get_viable_backendscCs.|j�d�\}}}|�dd�}d�||jg�S)zr
        The keyring name, suitable for display.

        The name is derived from module and class name.
        �.�_� )r�
rpartition�replace�joinr)r�parent�sep�mod_namerrrrMszKeyringBackend.namecCst|�}d|j|j|jfS)Nz%s.%s (priority: %g))�typerrr
)�selfZ
keyring_classrrr�__str__Ys
�zKeyringBackend.__str__cCsdS)z5Get password of the username for the service
        Nr�r4�service�usernamerrr�get_password_szKeyringBackend.get_passwordcCst�d��dS)z�Set password for the username of the service.

        If the backend cannot store passwords, raise
        NotImplementedError.
        �reasonN)rZPasswordSetError�r4r7r8Zpasswordrrr�set_passwordeszKeyringBackend.set_passwordcCst�d��dS)z�Delete the password for the username of the service.

        If the backend cannot store passwords, raise
        NotImplementedError.
        r:N)rZPasswordDeleteErrorr6rrr�delete_passwordqszKeyringBackend.delete_passwordcCs,|dk	r(|�||�}|dk	r(t�||�SdS)aGets the username and password for the service.
        Returns a Credential instance.

        The *username* argument is optional and may be omitted by
        the caller or ignored by the backend. Callers must use the
        returned username.
        N)r9rZSimpleCredentialr;rrr�get_credential|s	�zKeyringBackend.get_credentialN)rrrrr
rZ
ClassProperty�classmethodr&r)rr5�abc�abstractmethodr9r<r=r>rrrrr!(s"



r!c@s,eZdZdZejdd��Zejdd��ZdS)�Crypterz3Base class providing encryption and decryption
    cCsdS)zEncrypt the value.
        Nr�r4�valuerrr�encrypt�szCrypter.encryptcCsdS)zDecrypt the value.
        NrrCrrr�decrypt�szCrypter.decryptN)rrrrr@rArErFrrrrrB�s

rBc@s eZdZdZdd�Zdd�ZdS)�NullCrypterz A crypter that does nothing
    cCs|Sr#rrCrrrrE�szNullCrypter.encryptcCs|Sr#rrCrrrrF�szNullCrypter.decryptN)rrrrrErFrrrrrG�srGc	Csjd}tj|d�}|D]P}z(t�d|j�|��}t|�r>|�Wqtk
rbt�d|�YqXqdS)a
    Locate all setuptools entry points by the name 'keyring backends'
    and initialize them.
    Any third-party library may register an entry point by adding the
    following to their setup.py::

        entry_points = {
            'keyring.backends': [
                'plugin_name = mylib.mymodule:initialize_func',
            ],
        },

    `plugin_name` can be anything, and is only used to display the name
    of the plugin at initialization time.

    `initialize_func` is optional, but will be invoked if callable.
    zkeyring.backends)�groupz
Loading %szError initializing plugin %s.N)	�entrypointsZ
get_group_all�log�infor�load�callable�	ExceptionZ	exception)rHZentry_pointsZepZ	init_funcrrr�
_load_plugins�s
rOcCs$t�t��}tj|td�}t|�S)zc
    Return a list of all implemented keyrings that can be constructed without
    parameters.
    )�
exceptions)rOr!r)rZsuppress_exceptions�	TypeError�list)Zviable_classesZringsrrr�get_all_keyring�srS)rZ
__future__rr@Zloggingr'rI�rrrrZ
py27compatrr	r3Z
__metaclass__Z	getLoggerrrJr(Zby_priorityZ_limit�ABCMetarr!rBrGrO�oncerSrrrr�<module>s(

f