U
    Ó‡gþ  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   s>   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	d
„Zedd„ ƒZ	dS )ÚDictRegistryz+A simple registry for a mapping of objects.c                 C   s   |   ¡  d S ©N)Úreset©Úself© r   ú4/usr/lib/python3/dist-packages/cloudinit/registry.pyÚ__init__   s    zDictRegistry.__init__c                 C   s
   i | _ d S r   )Ú_itemsr   r   r   r   r      s    zDictRegistry.resetc                 C   s&   || j krtd |¡ƒ‚|| j |< dS )zAdd item to the registry.z$Item already registered with key {0}N)r
   Ú
ValueErrorÚformat)r   ÚkeyÚitemr   r   r   Úregister_item   s
    
ÿzDictRegistry.register_itemTc                 C   s(   || j kr| j |= n|s$td| ƒ‚dS )zRemove item from the registry.z!%s: key not present to unregisterN)r
   ÚKeyError)r   r   Zforcer   r   r   Úunregister_item   s    

zDictRegistry.unregister_itemc                 C   s   t   | j¡S )zvAll the items that have been registered.

        This cannot be used to modify the contents of the registry.
        )Úcopyr
   r   r   r   r   Úregistered_items    s    zDictRegistry.registered_itemsN)T)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   Úpropertyr   r   r   r   r   r      s   
r   )r   r   r   r   r   r   Ú<module>   s   