File: //usr/lib/python3/dist-packages/keyring/backends/__pycache__/SecretService.cpython-310.pyc
o
���a� � @ s� d dl mZ d dlZddlmZ ddlmZ ddlmZ ddl m
Z
mZmZm
Z
zd dlZd dlmZ W n ey= Y n eyE Y nw e�e�ZG dd � d e�ZdS )
� )�closingN� )�
properties)�KeyringBackend)�SimpleCredential)� InitError�PasswordDeleteError�ExceptionRaisedContext�
KeyringLockedc @ sV e Zd ZdZdZejedd� ��Zdd� Z dd� Z
d d
� Zdd� Zd
d� Z
dd� ZdS )�KeyringzSecret Service KeyringzPython keyring libraryc
C s� t � �}tj W d � n1 sw Y |rtd��tjdk r%td��z$tt�� ��}t�|�s6td��W d � W dS 1 sBw Y W dS tj y\ } ztd| ��d }~ww )NzSecretStorage required)� r z#SecretStorage 3.2 or newer requiredzJThe Secret Service daemon is neither running nor activatable through D-Busz&Unable to initialize SecretService: %s� )
r �
secretstorage�__name__�RuntimeError�__version_tuple__r � dbus_init�check_service_availability�
exceptions�SecretStorageException)�cls�exc�
connection�e� r �@/usr/lib/python3/dist-packages/keyring/backends/SecretService.py�priority s, �
�������zKeyring.priorityc
C s| t �� }zt| d�rt �|| j�}nt �|�}W n tjy+ } ztd| ��d}~ww |� � r<|�
� |� � r<td��|S )z�If self.preferred_collection contains a D-Bus path,
the collection at that address is returned. Otherwise,
the default collection is returned.
�preferred_collectionz$Failed to create the collection: %s.Nz Failed to unlock the collection!)r r �hasattr�
Collectionr �get_default_collectionr r r � is_locked�unlockr
)�self�bus�
collectionr r r r �get_preferred_collection3 s
���z Keyring.get_preferred_collectionc C s&