Close the current element (opened by the most recent call to :meth:`start`). Parameters ---------- tag Element tag. If given, the tag must match the start tag. If omitted, the current element is closed. indent : bool, defaul
(self, tag=None, indent=True)
| 193 | self.__data.append(text) |
| 194 | |
| 195 | def end(self, tag=None, indent=True): |
| 196 | """ |
| 197 | Close the current element (opened by the most recent call to |
| 198 | :meth:`start`). |
| 199 | |
| 200 | Parameters |
| 201 | ---------- |
| 202 | tag |
| 203 | Element tag. If given, the tag must match the start tag. If |
| 204 | omitted, the current element is closed. |
| 205 | indent : bool, default: True |
| 206 | """ |
| 207 | if tag: |
| 208 | assert self.__tags, f"unbalanced end({tag})" |
| 209 | assert _escape_cdata(tag) == self.__tags[-1], \ |
| 210 | f"expected end({self.__tags[-1]}), got {tag}" |
| 211 | else: |
| 212 | assert self.__tags, "unbalanced end()" |
| 213 | tag = self.__tags.pop() |
| 214 | if self.__data: |
| 215 | self.__flush(indent) |
| 216 | elif self.__open: |
| 217 | self.__open = 0 |
| 218 | self.__write("/>\n") |
| 219 | return |
| 220 | if indent: |
| 221 | self.__write(self.__indentation[:len(self.__tags)]) |
| 222 | self.__write(f"</{tag}>\n") |
| 223 | |
| 224 | def close(self, id): |
| 225 | """ |
no test coverage detected