code: def __init__(
      self,
      path: str | os.PathLike[str],
      data: str | None = None,
      encoding: str = "utf-8",
  ) -> None:
      self.path = os.fspath(path)
      if data is None:
          if os.path.basename(self.path).startswith("pkg:"):
              import pkgutil
  
              basename = os.path.basename(self.path)
              _, package, resource = basename.split(":")
              content = pkgutil.get_data(package, resource)
              data = content.decode("utf-8")
          else:
              with open(self.path, encoding=encoding) as fp:
                  data = fp.read()
  
      tokens = _parse.parse_lines(self.path, data.splitlines(True))
  
      self._sources = {}
      sections_data: dict[str, dict[str, str]]
      self.sections = sections_data = {}
  
      for lineno, section, name, value in tokens:
          if section is None:
              raise ParseError(
                  self.path, lineno, "no section header defined"
              )
          self._sources[section, name] = lineno
          if name is None:
              if section in self.sections:
                  raise ParseError(
                      self.path,
                      lineno,
                      f"duplicate section {section!r}",
                  )
              sections_data[section] = {}
          else:
              if name in self.sections[section]:
                  raise ParseError(
                      self.path, lineno, f"duplicate name {name!r}"
                  )
              assert value is not None
              sections_data[section][name] = value
  
imports: from __future__ import annotations
  from typing import Callable, Iterator, Mapping, Optional, Tuple, TypeVar, Union, TYPE_CHECKING, NoReturn, NamedTuple, overload, cast
  import os
  from .exceptions import ParseError
  from .None import _parse
  from ._parse import COMMENTCHARS, iscommentline
label_desc: Use image node_id 1 to create a new IniConfig object  with example: obj = IniConfig(path, data, encoding)