JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/plugins/__pycache__/storage.cpython-39.pyc

a

}|�g��@sxdZddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
ddl	mZe�e
�ZGd	d
�d
�ZdS)zPlugin storage class.�N)�Any)�Dict)�
configuration)�errors)�
filesystem)�osc@speZdZdZejedd�dd�Zdd�dd�Zdd�d	d
�Z	dd�dd�Z
eedd
�dd�Zeed�dd�Z
dS)�
PluginStoragez4Class implementing storage functionality for pluginsN)�config�classkey�returncCs||_||_d|_||dS)z�Initializes PluginStorage object storing required configuration
        options.

        :param .configuration.NamespaceConfig config: Configuration object
        :param str classkey: class name to use as root key in storage file

        FN)�_config�	_classkey�_initialized)�selfr	r
�r�;/usr/lib/python3.9/site-packages/certbot/plugins/storage.py�__init__s
	zPluginStorage.__init__)rcCs&tj�|jjd�|_|��d|_dS)zhInitializes PluginStorage data and reads current state from the disk
        if the storage json exists.z.pluginstorage.jsonTN)r�path�joinrZ
config_dir�_storagepath�_loadr)rrrr�_initialize_storage!sz!PluginStorage._initialize_storagec
Cs�i}d}z8t|jd��}|��}Wd�n1s40YWnXty�}z@d�|jt|��}tj�|j�r�t	�
|�t�|��WYd}~n
d}~00zt
�|�}WnFty�|s�t	�d|j�n d�|j�}t	�
|�t�|��Yn0||_dS)z�Reads PluginStorage content from the disk to a dict structure

        :raises .errors.PluginStorageError: when unable to open or read the file
        ��rNz1Could not read PluginStorage data file: {0} : {1}z2Plugin storage file %s was empty, no values loadedz$PluginStorage file {0} is corrupted.)�openr�read�OSError�format�strrr�isfile�logger�errorr�PluginStorageError�json�loads�
ValueError�debug�_data)r�dataZfiledata�fh�e�errmsgrrrr)s2*
�
 ��
zPluginStorage._loadc
Cs|jsd}t�|�t�|��zt�|j�}WnFtyt}z.d�	t
|��}t�|�t�|��WYd}~n
d}~00zTt�t
�|jtjtjBtjBd�d��}|�|�Wd�n1s�0YWnLt�y}z2d�	|jt
|��}t�|�t�|��WYd}~n
d}~00dS)z�Saves PluginStorage content to disk

        :raises .errors.PluginStorageError: when unable to serialize the data
            or write it to the filesystem
        z;Unable to save, no values have been added to PluginStorage.z+Could not serialize PluginStorage data: {0}Ni��wz4Could not write PluginStorage data to file {0} : {1})rr r!rr"r#�dumpsr'�	TypeErrorrrr�fdopenrrr�O_WRONLY�O_CREAT�O_TRUNC�writer)rr+Z
serializedr*r)rrr�saveGs8

�
 ��,
�
zPluginStorage.save)�key�valuercCs:|js|��|j|jvr&i|j|j<||j|j|<dS)z�Put configuration value to PluginStorage

        :param str key: Key to store the value to
        :param value: Data to store
        N)rrr
r')rr5r6rrr�putes
zPluginStorage.put)r5rcCs|js|��|j|j|S)z�Get configuration value from PluginStorage

        :param str key: Key to get value from the storage

        :raises KeyError: If the key doesn't exist in the storage
        )rrr'r
)rr5rrr�fetchrszPluginStorage.fetch)�__name__�
__module__�__qualname__�__doc__rZNamespaceConfigrrrrr4rr7r8rrrrrs
r)r<r#Zlogging�typingrrZcertbotrrZcertbot.compatrrZ	getLoggerr9r rrrrr�<module>s

Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬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