
import luna.plugins

_configurations = {}
"""
The configuration classes that have been registered here so far, keyed by their
identities.
"""

def register(identity, metadata):
	"""
	Registers a new configuration plug-in to track configuration with.

	This expects the metadata to already be verified as configuration's
	metadata.

	:param identity: The identity of the plug-in to register.
	:param metadata: The metadata of a configuration plug-in.
	"""
	if identity in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is already registered.", configuration=identity)
		return
	_configurations[identity] = metadata["configuration"]["class"]

def unregister(identity):
	raise Exception("Not implemented yet.")

def validate_metadata(metadata):
	raise Exception("Not implemented yet.")

import luna.plugins

_configurations = {}
"""
The configuration classes that have been registered here so far, keyed by their
identities.
"""

def register(identity, metadata):
	"""
	Registers a new configuration plug-in to track configuration with.

	This expects the metadata to already be verified as configuration's
	metadata.

	:param identity: The identity of the plug-in to register.
	:param metadata: The metadata of a configuration plug-in.
	"""
	if identity in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is already registered.", configuration=identity)
		return
	_configurations[identity] = metadata["configuration"]["class"]

def unregister(identity):
	"""
	Undoes the registration of a configuration plug-in.

	The configuration plug-in will no longer keep track of any configuration.
	Existing configuration will be stored persistently.

	:param identity: The identity of the plug-in to unregister.
	"""
	if identity not in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is not registered, so I can't unregister it.", configuration=identity)
		return
	del _configurations[identity] #The actual unregistration.

def validate_metadata(metadata):
	raise Exception("Not implemented yet.")
Implement unregistration of configuration plug-ins
Implement unregistration of configuration plug-ins

Perhaps we should not give a warning, but instead an exception, when registering or unregistering fails?

  
  import luna.plugins
  
  _configurations = {}
  """
  The configuration classes that have been registered here so far, keyed by their
  identities.
  """
  
  def register(identity, metadata):
  	"""
  	Registers a new configuration plug-in to track configuration with.
  
  	This expects the metadata to already be verified as configuration's
  	metadata.
  
  	:param identity: The identity of the plug-in to register.
  	:param metadata: The metadata of a configuration plug-in.
  	"""
  	if identity in _configurations:
  		luna.plugins.api("logger").warning("Configuration {configuration} is already registered.", configuration=identity)
  		return
  	_configurations[identity] = metadata["configuration"]["class"]
  
  def unregister(identity):
- 	raise Exception("Not implemented yet.")
+ 	"""
+ 	Undoes the registration of a configuration plug-in.
+ 
+ 	The configuration plug-in will no longer keep track of any configuration.
+ 	Existing configuration will be stored persistently.
+ 
+ 	:param identity: The identity of the plug-in to unregister.
+ 	"""
+ 	if identity not in _configurations:
+ 		luna.plugins.api("logger").warning("Configuration {configuration} is not registered, so I can't unregister it.", configuration=identity)
+ 		return
+ 	del _configurations[identity] #The actual unregistration.
  
  def validate_metadata(metadata):
  	raise Exception("Not implemented yet.")
Implement unregistration of configuration plug-ins
## Code Before:

import luna.plugins

_configurations = {}
"""
The configuration classes that have been registered here so far, keyed by their
identities.
"""

def register(identity, metadata):
	"""
	Registers a new configuration plug-in to track configuration with.

	This expects the metadata to already be verified as configuration's
	metadata.

	:param identity: The identity of the plug-in to register.
	:param metadata: The metadata of a configuration plug-in.
	"""
	if identity in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is already registered.", configuration=identity)
		return
	_configurations[identity] = metadata["configuration"]["class"]

def unregister(identity):
	raise Exception("Not implemented yet.")

def validate_metadata(metadata):
	raise Exception("Not implemented yet.")
## Instruction:
Implement unregistration of configuration plug-ins
## Code After:

import luna.plugins

_configurations = {}
"""
The configuration classes that have been registered here so far, keyed by their
identities.
"""

def register(identity, metadata):
	"""
	Registers a new configuration plug-in to track configuration with.

	This expects the metadata to already be verified as configuration's
	metadata.

	:param identity: The identity of the plug-in to register.
	:param metadata: The metadata of a configuration plug-in.
	"""
	if identity in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is already registered.", configuration=identity)
		return
	_configurations[identity] = metadata["configuration"]["class"]

def unregister(identity):
	"""
	Undoes the registration of a configuration plug-in.

	The configuration plug-in will no longer keep track of any configuration.
	Existing configuration will be stored persistently.

	:param identity: The identity of the plug-in to unregister.
	"""
	if identity not in _configurations:
		luna.plugins.api("logger").warning("Configuration {configuration} is not registered, so I can't unregister it.", configuration=identity)
		return
	del _configurations[identity] #The actual unregistration.

def validate_metadata(metadata):
	raise Exception("Not implemented yet.")