def METHOD_NAME(self, out):
    _outinifile = self._inifile or INIConfig(optionxformvalue=None)
    for unit in self.units:
        for location in unit.getlocations():
            match = re.match("\\[(?P<section>.+)\\](?P<entry>.+)", location)
            if match is None:
                section = "default"
                entry = location
            else:
                section = match.groupdict()["section"]
                entry = match.groupdict()["entry"]
            value = self._dialect.escape(unit.target)
            _outinifile[section][entry] = value
    if _outinifile:
        out.write(str(_outinifile).encode("utf-8"))