import re


def name_value_to_dict(content):
  """Converts a list of name=value pairs to a dictionary.

  Args:
    content: [string] A list of name=value pairs with one per line.
             This is blank lines ignored, as is anything to right of '#'.
  """
  result = {}
  for match in re.finditer('^([A-Za-z_][A-Za-z0-9_]*) *= *([^#]*)',
                           content, re.MULTILINE):
    result[match.group(1)] = match.group(2).strip()
  return result