HEX
Server: nginx/1.30.4
System: Linux d-twindigital-web-1.host-ed.eu 4.18.0-553.141.2.el8_10.x86_64 #1 SMP Wed Jul 8 10:28:18 EDT 2026 x86_64
User: u_twindigital_html (1009)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/certbot/plugins/__pycache__/storage.cpython-36.opt-1.pyc
3

ߦ)_r�@sndZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
eje�Z
Gdd	�d	e�ZdS)
zPlugin storage class.�N)�Any)�Dict)�errors)�
filesystem)�osc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
PluginStoragez4Class implementing storage functionality for pluginscCs"||_||_d|_d|_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�_data�_storagepath)�self�configZclasskey�r�/usr/lib/python3.6/storage.py�__init__s
	zPluginStorage.__init__cCs&tjj|jjd�|_|j�d|_dS)zhInitializes PluginStorage data and reads current state from the disk
        if the storage json exists.z.pluginstorage.jsonTN)r�path�joinrZ
config_dirr�_loadr
)r
rrr�_initialize_storage sz!PluginStorage._initialize_storagecCs�i}d}y$t|jd��}|j�}WdQRXWnVtk
r�}z:dj|jt|��}tjj|j�rrt	j
|�tj|��WYdd}~XnXyt
j|�}WnHtk
r�|s�t	jd|j�n dj|j�}t	j
|�tj|��YnX||_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�IOError�format�strrr�isfile�logger�errorr�PluginStorageError�json�loads�
ValueError�debugr)r
�dataZfiledata�fh�e�errmsgrrrr(s,


zPluginStorage._loadcCs|jsd}tj|�tj|��ytj|j�}WnDtk
rr}z(dj	t
|��}tj|�tj|��WYdd}~XnXy@tjt
j|jtjtjBtjBd�d��}|j|�WdQRXWnHtk
r�}z,dj	|jt
|��}tj|�tj|��WYdd}~XnXdS)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})r
rrrr r!�dumpsr�	TypeErrorrrr�fdopenrrr�O_WRONLY�O_CREAT�O_TRUNC�writer)r
r(Z
serializedr'r&rrr�saveFs,




zPluginStorage.savecCs>|js|j�|j|jj�kr*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)r
rr	r�keys)r
�key�valuerrr�putds
zPluginStorage.putcCs|js|j�|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
        )r
rrr	)r
r3rrr�fetchqszPluginStorage.fetchN)
�__name__�
__module__�__qualname__�__doc__rrrr1r5r6rrrrrs
r)r:r!ZloggingZacme.magic_typingrrZcertbotrZcertbot.compatrrZ	getLoggerr7r�objectrrrrr�<module>s