def write_config(config, path, variables=None):
 f = file(path, 'w')
 try:
  f.write('<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<configuration>\n')
  keys = ((variables and (variables,)) or (config.keys(),))[0]
  for name in keys:
   value = config[name]
   f.write('  <property>\n')
   f.write(('    <name>%s</name>\n' % name))
   f.write(('    <value>%s</value>\n' % value))
   f.write('  </property>\n')
  f.write('</configuration>\n')
 finally:
  f.close()

def write_config ( config , path , variables = None ) : f = file ( path , 'w' ) try : f . write ( '<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<configuration>\n' ) keys = ( ( variables and ( variables , ) ) or ( config . keys ( ) , ) ) [ 0 ] for name in keys : value = config [ name ] f . write ( '  <property>\n' ) f . write ( ( '    <name>%s</name>\n' % name ) ) f . write ( ( '    <value>%s</value>\n' % value ) ) f . write ( '  </property>\n' ) f . write ( '</configuration>\n' ) finally : f . close ( )
minimal utility to write hadoop-style configuration from a configuration map .