def write_keyval(path, dictionary, type_tag=None, tap_report=None):
 if os.path.isdir(path):
  path = os.path.join(path, 'keyval')
 keyval = open(path, 'a')
 if (type_tag is None):
  key_regex = re.compile('^[-\\.\\w]+$')
 else:
  if (type_tag not in ('attr', 'perf')):
   raise ValueError(('Invalid type tag: %s' % type_tag))
  escaped_tag = re.escape(type_tag)
  key_regex = re.compile(('^[-\\.\\w]+\\{%s\\}$' % escaped_tag))
 try:
  for key in sorted(dictionary.keys()):
   if (not key_regex.search(key)):
    raise ValueError(('Invalid key: %s' % key))
   keyval.write(('%s=%s\n' % (key, dictionary[key])))
 finally:
  keyval.close()
 if ((tap_report is not None) and tap_report.do_tap_report):
  tap_report.record_keyval(path, dictionary, type_tag=type_tag)

def write_keyval ( path , dictionary , type_tag = None , tap_report = None ) : if os . path . isdir ( path ) : path = os . path . join ( path , 'keyval' ) keyval = open ( path , 'a' ) if ( type_tag is None ) : key_regex = re . compile ( '^[-\\.\\w]+$' ) else : if ( type_tag not in ( 'attr' , 'perf' ) ) : raise ValueError ( ( 'Invalid type tag: %s' % type_tag ) ) escaped_tag = re . escape ( type_tag ) key_regex = re . compile ( ( '^[-\\.\\w]+\\{%s\\}$' % escaped_tag ) ) try : for key in sorted ( dictionary . keys ( ) ) : if ( not key_regex . search ( key ) ) : raise ValueError ( ( 'Invalid key: %s' % key ) ) keyval . write ( ( '%s=%s\n' % ( key , dictionary [ key ] ) ) ) finally : keyval . close ( ) if ( ( tap_report is not None ) and tap_report . do_tap_report ) : tap_report . record_keyval ( path , dictionary , type_tag = type_tag )
write a key-value pair format file out to a file .