def test_dxf_escape_line_endings(): assert escape_dxf_line_endings('\\P test') == '\\P test' assert escape_dxf_line_endings('abc\ndef') == 'abc\\Pdef' assert escape_dxf_line_endings('abc\rdef') == 'abcdef', \ r"a single '\r' should be ignored" assert escape_dxf_line_endings('abc\r\ndef') == 'abc\\Pdef', \ r"'\r\n' represents a single newline"
def test_dxf_escape_line_endings(): assert escape_dxf_line_endings("\\P test") == "\\P test" assert escape_dxf_line_endings("abc\ndef") == "abc\\Pdef" assert ( escape_dxf_line_endings("abc\rdef") == "abcdef" ), r"a single '\r' should be ignored" assert ( escape_dxf_line_endings("abc\r\ndef") == "abc\\Pdef" ), r"'\r\n' represents a single newline"
def export_mtext(self, tagwriter: 'TagWriter') -> None: txt = escape_dxf_line_endings(self.text) str_chunks = split_mtext_string(txt, size=250) if len(str_chunks) == 0: str_chunks.append("") while len(str_chunks) > 1: tagwriter.write_tag2(3, str_chunks.pop(0)) tagwriter.write_tag2(1, str_chunks[0])
def load_mtext(self, tags: Tags) -> Iterable['DXFTag']: tail = "" parts = [] for tag in tags: if tag.code == 1: tail = tag.value elif tag.code == 3: parts.append(tag.value) else: yield tag parts.append(tail) self.text = escape_dxf_line_endings(caret_decode("".join(parts)))