def KeyValueStringToDict(s, delimiter='|'):
  """Parses a key=value string with delimiter and returns a dict.

  Args:
    s: string with key=value pairs.
    delimiter: delimiter char(s) to parse the string with.
  Returns:
    dictionary of key value pairs. 'None' converted to None.
  """
  d = {}
  pairs = s.split(delimiter)
  for pair in pairs:
    try:
      key, value = pair.split('=', 1)
      if not value or value == 'None':
        value = None  # Convert empty strings to None.
      d[key] = value
    except __HOLE__:
      logging.debug('Ignoring invalid key/value pair: %s', pair)
  return d
dataset/ETHPy150Open google/simian/src/simian/mac/munki/common.py/KeyValueStringToDict