%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/secretstorage/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/secretstorage/__pycache__/collection.cpython-312.pyc

�

��b�$��T�dZddlmZmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZddlmZddlmZmZmZmZmZed	zZed
zZdZdZGd
�d	�Z		ddedededeedef
d�Zdedeefd�Z	ddedeedefd�Z dedefd�Z!dededefd�Z"dedeeefdeefd�Z#y)arCollection is a place where secret items are stored. Normally, only
the default collection should be used, but this module allows to use any
registered collection. Use :func:`get_default_collection` to get the
default collection (and create it, if necessary).

Collections are usually automatically unlocked when user logs in, but
collections can also be locked and unlocked using
:meth:`Collection.lock` and :meth:`Collection.unlock` methods (unlocking
requires showing the unlocking prompt to user and can be synchronous or
asynchronous). Creating new items and editing existing ones is possible
only in unlocked collection.�)�Dict�Iterator�Optional)�DBusConnection)�	SS_PREFIX�SS_PATH)�Session)�LockedException�ItemNotFoundException�PromptDismissedException)�Item)�DBusAddressWrapper�exec_prompt�
format_secret�open_session�unlock_objects�
Collection�Servicez(/org/freedesktop/secrets/aliases/defaultz+/org/freedesktop/secrets/collection/sessionc
���eZdZdZedfdededeeddfd�Z	de
fd�Zdd	�Zde
fd
�Z
dd�Zdd�Zdeefd
�Zdeeefdeefd�Zdefd�Zdeddfd�Z		ddedeeefdede
dedefd�Zy)rzRepresents a collection.N�
connection�collection_path�session�returnc��||_||_||_t|t|�|_|j
j
d�y)N�Label)rrrr�COLLECTION_IFACE�_collection�get_property)�selfrrrs    �:/usr/lib/python3/dist-packages/secretstorage/collection.py�__init__zCollection.__init__%sC��%������.���-��-�z�;������%�%�g�.�c�J�t|jjd��S)zJReturns :const:`True` if item is locked, otherwise
        :const:`False`.�Locked)�boolrr�rs r �	is_lockedzCollection.is_locked/s ���D�$�$�1�1�(�;�<�<r"c�:�|j�rtd��y)zYIf collection is locked, raises
        :exc:`~secretstorage.exceptions.LockedException`.zCollection is locked!N)r'r
r&s r �ensure_not_lockedzCollection.ensure_not_locked4s���>�>��!�"9�:�:�r"c�D�t|j|jg�S)aARequests unlocking the collection.

        Returns a boolean representing whether the prompt has been
        dismissed; that means :const:`False` on successful unlocking
        and :const:`True` if it has been dismissed.

        .. versionchanged:: 3.0
           No longer accepts the ``callback`` argument.
        )rrrr&s r �unlockzCollection.unlock:s���d�o�o��0D�0D�/E�F�Fr"c�~�ttt|j�}|j	dd|j
g�y)zLocks the collection.�Lock�aoN)rr�
SERVICE_IFACEr�callr)r�services  r �lockzCollection.lockFs-��$�W�m�T�_�_�M�����V�T�D�$8�$8�#9�:r"c��|j�|jjdd�\}|dk7r't|j|�\}}|rtd��yy)z/Deletes the collection and all items inside it.�Delete��/�Prompt dismissed.N)r)rr0rrr)r�prompt�	dismissed�_results    r �deletezCollection.deleteKs]����� ��"�"�'�'��"�5����S�=�!,�T�_�_�f�!E��I�w��.�/B�C�C��r"c#�K�|jjd�D]%}t|j||j����'y�w)z3Returns a generator of all items in the collection.�ItemsN)rrr
rr)r�	item_paths  r �
get_all_itemszCollection.get_all_itemsTs?�����)�)�6�6�w�?�	A�I��t���	�4�<�<�@�@�	A���AA�
attributesc#�K�|jjdd|�\}|D]%}t|j||j����'y�w)zdReturns a generator of items with the given attributes.
        `attributes` should be a dictionary.�SearchItems�a{ss}N)rr0r
rr)rrA�resultr>s    r �search_itemszCollection.search_itemsYsL�����"�"�'�'�
�w�
�K����	A�I��t���	�4�<�<�@�@�	A�s�AA
c�`�|jjd�}t|t�sJ�|S)zReturns the collection label.r)rr�
isinstance�str�r�labels  r �	get_labelzCollection.get_label`s-��� � �-�-�g�6���%��%�%�%��r"rKc�^�|j�|jjdd|�y)z!Sets collection label to `label`.r�sN)r)r�set_propertyrJs  r �	set_labelzCollection.set_labelfs&����� ����%�%�g�s�E�:r"�secret�replace�content_typec��|j�|jst|j�|_t	|j||�}t
dzd|ft
dzd|fi}|jjdd|||�\}}	t|�dkDr!t|j||j�St|j|	�\}
}|
rtd��|\}}|d	k(sJ�t|j||j�S)
a�Creates a new :class:`~secretstorage.item.Item` with given
        `label` (unicode string), `attributes` (dictionary) and `secret`
        (bytestring). If `replace` is :const:`True`, replaces the existing
        item with the same attributes. If `content_type` is given, also
        sets the content type of the secret (``text/plain`` by default).
        Returns the created item.z
Item.LabelrNzItem.AttributesrD�
CreateItemza{sv}(oayays)b�r7�o)r)rrrrrrr0�lenr
rr)
rrKrArQrRrS�_secret�
propertiesr>r8r9rE�	signatures
             r �create_itemzCollection.create_itemks��	
��� ��|�|�'����8�D�L�����f�l�C����$�s�E�l��)�)�G�Z�+@�
�
�!�,�,�1�1������
��	�6��y�>�A�������D�L�L�A�A�'�����@��	�6��*�+>�?�?�%��	�9��C�����D�O�O�Y����=�=r")rN)Fz
text/plain)�__name__�
__module__�__qualname__�__doc__�DEFAULT_COLLECTIONrrIrr	r!r%r'r)r+r2r;rr
r?rrFrLrP�bytesr\�r"r rr"s���"�);�.2�/�>�/�"%�/�"�7�+�/�7;�/�=�4�=�
;�
G��
G�;�
D�A�x��~�A�
A�t�C��H�~�A�(�4�.�A��3��;�s�;�t�;�49�(4�>��>�$�s�C�x�.�>�!�>�,0�>�"%�>�9=�>r"NrrK�aliasrrc�2�|st|�}tdzd|fi}ttt|�}|jdd||�\}}t
|�dkDrt|||��St||�\}}	|rtd��|	\}
}|
dk(sJ�t|||��S)	z�Creates a new :class:`Collection` with the given `label` and `alias`
    and returns it. This action requires prompting.

    :raises: :exc:`~secretstorage.exceptions.PromptDismissedException`
             if the prompt is dismissed.
    zCollection.LabelrN�CreateCollectionza{sv}srV)rr7rW)
rrrrr/r0rXrrr)rrKrdrrZr1rr8r9rEr[s           r �create_collectionrg�s�����z�*���0�0�3��,�?�J� ��-��D�G�%�l�l�+=�x�+5�u�>��O�V�
�?��a���*�o�w�G�G�#�J��7��I�v��&�':�;�;�!'��I��������j�/�7�C�Cr"c#�~K�ttt|�}|jd�D]}t	||����y�w)z1Returns a generator of all available collections.�CollectionsN)rrr/rr)rr1rs   r �get_all_collectionsrj�s;���� ��-��D�G�"�/�/�
�>�6����_�5�5�6�s�;=c�T�	t|�S#t$rt|dd|�cYSwxYw)zDReturns the default collection. If it doesn't exist,
    creates it.�Default�default)rrrg)rrs  r �get_default_collectionrn�s5��L��*�%�%�� �L� ��Y�	�7�K�K�L�s�

�'�'c���	t|�S#t$rYnwxYw	t|t�S#t$rYnwxYwtt	|��}|r|dStd��)z�Returns any collection, in the following order of preference:

    - The default collection;
    - The "session" collection (usually temporary);
    - The first collection in the collections list.rzNo collections found.)rr�SESSION_COLLECTION�listrj)r�collectionss  r �get_any_collectionrs�st��
��*�%�%�� �
��
��
��*�&8�9�9�� �
��
���*�:�6�7�K���1�~��#�$;�<�<s�

�	��-�	9�9c��ttt|�}|jdd|�\}t	|�dkrtd��t
||�S)z�Returns the collection with the given `alias`. If there is no
    such collection, raises
    :exc:`~secretstorage.exceptions.ItemNotFoundException`.�	ReadAliasrNrVzNo collection with such alias.)rrr/r0rXrr)rrdr1rs    r �get_collection_by_aliasrv�sM��
!��-��D�G��|�|�K��e�<��O�
�?��q� �#�$D�E�E��j�/�2�2r"rAc#�K�ttt|�}|jdd|�\}}||zD]}t	||����y�w)zsReturns a generator of items in all collections with the given
    attributes. `attributes` should be a dictionary.rCrDN)rrr/r0r
)rrAr1�locked�unlockedr>s      r rFrF�sN����!��-��D�G��|�|�M�7�J�G��F�H��h�&�*�	��:�y�)�)�*�r@)r5N)N)$r`�typingrrr�jeepney.io.blockingr�secretstorage.definesrr�secretstorage.dhcryptor	�secretstorage.exceptionsr
rr�secretstorage.itemr
�secretstorage.utilrrrrrrr/rarprrIrgrjrnrsrvrFrcr"r �<module>r�s:��
 �,�+�.�4�*���#�-�-��|�+���I�%�
�?��B��h>�h>�VLN�37�D�.�D��D�S�D�'��0�D�<F�D�06�N�6�x�
�7K�6�9=�L�~�L�$,�W�$5�L�AK�L�=�>�=�j�=�.	3��	3�#&�	3�+5�	3�*�^�*�!�#�s�(�^�*�08���*r"

Zerion Mini Shell 1.0