1
# Copyright 2015 Canonical Ltd.
2
# This file is part of cloud-init. See LICENCE file for license information.
8
class DictRegistry(object):
9
"""A simple registry for a mapping of objects."""
17
def register_item(self, key, item):
18
"""Add item to the registry."""
19
if key in self._items:
21
'Item already registered with key {0}'.format(key))
22
self._items[key] = item
24
def unregister_item(self, key, force=True):
25
"""Remove item from the registry."""
26
if key in self._items:
29
raise KeyError("%s: key not present to unregister" % key)
32
def registered_items(self):
33
"""All the items that have been registered.
35
This cannot be used to modify the contents of the registry.
37
return copy.copy(self._items)