+def write_config(config, config_path, sanity_check=True):
+ """
+ Writes the configuration to given path.
+
+ Parameters
+ ----------
+ config : Config
+ *OCIO* configuration.
+ config_path : str or unicode
+ Path to write the configuration path.
+ sanity_check : bool
+ Performs configuration sanity checking prior to writing it on disk.
+
+ Returns
+ -------
+ bool
+ Definition success.
+ """
+
+ if sanity_check:
+ try:
+ config.sanityCheck()
+ except Exception, e:
+ print e
+ print 'Configuration was not written due to a failed Sanity Check'
+ return
+
+ with open(config_path, mode='w') as fp:
+ fp.write(config.serialize())
+
+