code: def parse_dotenv(content: str) -> dict[str, t.Any]:
      env: dict[str, t.Any] = {}
  
      for line in content.splitlines():
          m1 = line_re.search(line)
  
          if m1:
              key, value = m1.groups()
  
              if value is None:
                  value = ""
  
              # Remove leading/trailing whitespace
              value = value.strip()
  
              # Remove surrounding quotes
              m2 = re.match(r'^([\'"])(.*)\1$', value)
  
              if m2:
                  quotemark, value = m2.groups()
              else:
                  quotemark = None
  
              # Unescape all chars except $ so variables can be escaped properly
              if quotemark == '"':
                  value = re.sub(r"\\([^$])", r"\1", value)
  
              if quotemark != "'":
                  # Substitute variables in a value
                  for parts in variable_re.findall(value):
                      if parts[0] == "\\":
                          # Variable is escaped, don't replace it
                          replace = "".join(parts[1:-1])
                      else:
                          # Replace it with the value from the environment
                          replace = env.get(
                              parts[-1], os.environ.get(parts[-1], "")
                          )
  
                      value = value.replace(
                          "".join(parts[0:-1]), replace
                      )
  
              env[key] = value
  
          elif not re.search(
              r"^\s*(?:#.*)?$", line
          ):  # not comment or blank
              logger.warning("Line %r doesn't match format", repr(line))
  
      return env
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: parse_dotenv(content) and returns: env