/
lib
/
python3
/
dist-packages
/
certbot
/
plugins
/
__pycache__
/
Upload File
HOME
� E��c� � � � d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddl m Z ddl mZ ej e � � Z G d � d � � ZdS )zPlugin storage class.� N)�Any)�Dict)� configuration)�errors)� filesystem)�osc �l � e Zd ZdZdej deddfd�Zdd�Zdd�Z dd �Z d ededdfd�Zd edefd �Z dS )� PluginStoragez4Class implementing storage functionality for plugins�config�classkey�returnNc �8 � || _ || _ 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 s �9/usr/lib/python3/dist-packages/certbot/plugins/storage.py�__init__zPluginStorage.__init__ s, � � ���!���!��������� c � � t j � | j j d� � | _ | � � � d| _ dS )zhInitializes PluginStorage data and reads current state from the disk if the storage json exists.z.pluginstorage.jsonTN)r �path�joinr � config_dir�_storagepath�_loadr )r s r �_initialize_storagez!PluginStorage._initialize_storage! s= � � �G�L�L���)@�BW�X�X���� � ���� ����r c �� � i }d} t | j d� � 5 }|� � � }ddd� � n# 1 swxY w Y n�# t $ r�}d� | j t |� � � � }t j � | j � � r.t � |� � t j |� � �Y d}~nd}~ww xY w t j |� � }n{# t $ rn |s!t � d| j � � nHd� | j � � }t � |� � t j |� � �Y nw xY w|| _ 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�strr r �isfile�logger�errorr �PluginStorageError�json�loads� ValueError�debug�_data)r �data�filedata�fh�e�errmsgs r r zPluginStorage._load) s� � � "���� 8��d�'��-�-� %���7�7�9�9�� %� %� %� %� %� %� %� %� %� %� %���� %� %� %� %���� 8� 8� 8�H�O�O��!�3�q�6�6�+� +�F��w�~�~�d�/�0�0� 8����V�$�$�$��/��7�7�7� 8� 8� 8� 8� 8����� 8���� 8��:�h�'�'�D�D��� 8� 8� 8�� 8����Q�!�.�0� 0� 0� 0� @�F�F��%�'� '�����V�$�$�$��/��7�7�7� 0� 0� 8���� �� � � sK �A �<�A �A � A �A �A � C�A:C�C�C/ �/A5E'�&E'c �@ � | j s0d}t � |� � t j |� � � t j | j � � }nb# t $ rU}d� t |� � � � }t � |� � t j |� � �d}~ww xY w t j t j | j t j t j z t j z d� � d� � 5 }|� |� � ddd� � dS # 1 swxY w Y dS # t( $ r[}d� | j t |� � � � }t � |� � t j |� � �d}~ww xY w)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 r&