
"·T`  ã               @   s&   d  d l  Z  Gd d „  d e ƒ 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   |  j  ƒ  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)N)Ú_items)r   r   r   r   r      s    zDictRegistry.resetc             C   s5   | |  j  k r$ t d j | ƒ ƒ ‚ | |  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   s6   | |  j  k r |  j  | =n | s2 t d | ƒ ‚ d S)zRemove item from the registry.z!%s: key not present to unregisterN)r   ÚKeyError)r   r   Úforcer   r   r   Úunregister_item   s    zDictRegistry.unregister_itemc             C   s   t  j  |  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)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Úpropertyr   r   r   r   r   r      s   r   )r   Úobjectr   r   r   r   r   Ú<module>   s   