Write an .ini-format representation of the configuration state. If `space_around_delimiters` is True (the default), delimiters between keys and values are surrounded by spaces. Please note that comments in the original configuration file are not preserved when writi
(self, fp, space_around_delimiters=True)
| 952 | sectdict[self.optionxform(option)] = value |
| 953 | |
| 954 | def write(self, fp, space_around_delimiters=True): |
| 955 | """Write an .ini-format representation of the configuration state. |
| 956 | |
| 957 | If `space_around_delimiters` is True (the default), delimiters |
| 958 | between keys and values are surrounded by spaces. |
| 959 | |
| 960 | Please note that comments in the original configuration file are not |
| 961 | preserved when writing the configuration back. |
| 962 | """ |
| 963 | if space_around_delimiters: |
| 964 | d = " {} ".format(self._delimiters[0]) |
| 965 | else: |
| 966 | d = self._delimiters[0] |
| 967 | if self._defaults: |
| 968 | self._write_section(fp, self.default_section, |
| 969 | self._defaults.items(), d) |
| 970 | if UNNAMED_SECTION in self._sections and self._sections[UNNAMED_SECTION]: |
| 971 | self._write_section(fp, UNNAMED_SECTION, self._sections[UNNAMED_SECTION].items(), d, unnamed=True) |
| 972 | |
| 973 | for section in self._sections: |
| 974 | if section is UNNAMED_SECTION: |
| 975 | continue |
| 976 | self._write_section(fp, section, |
| 977 | self._sections[section].items(), d) |
| 978 | |
| 979 | def _write_section(self, fp, section_name, section_items, delimiter, unnamed=False): |
| 980 | """Write a single section to the specified 'fp'.""" |
no test coverage detected