def test_replace_text_soft_page_break(self): input_xml = ( HEADER + "<text:p>Before</text:p>" + "<text:p text:style-name='code'>" + "<text:soft-page-break/>${test.cpp}" + "</text:p>" + "<text:p>After</text:p>" + FOOTER ) tree = etree.fromstring(input_xml) expected_xml = ( HEADER + "<text:p>Before</text:p>" + "<text:p text:style-name='code'>line1</text:p>" + "<text:p text:style-name='code'>line2</text:p>" + "<text:p>After</text:p>" + FOOTER ) expected_tree = etree.fromstring(expected_xml) dct = {"test.cpp": "line1\nline2"} replacer.replace_placeholders(tree, dct) self._compare_trees(tree, expected_tree)
def main(): parser = OptionParser(usage=USAGE, description=DESCRIPTION) (options, args) = parser.parse_args() if len(args) != 3: parser.error("Missing arguments") odt_input_name = args[0] odt_output_name = args[1] txt_dir = args[2] odt = OdtFile(odt_input_name) cache = TextFileCache(txt_dir) replacer.replace_placeholders(odt.tree, cache) odt.save(odt_output_name) return 0
def test_replace_text_p(self): input_xml = HEADER \ + "<text:p>Before</text:p>" \ + "<text:p text:style-name='code'>${test.cpp}</text:p>" \ + "<text:p>After</text:p>" \ + FOOTER tree = etree.fromstring(input_xml) expected_xml = HEADER \ + "<text:p>Before</text:p>" \ + "<text:p text:style-name='code'>line1</text:p>" \ + "<text:p text:style-name='code'>line2</text:p>" \ + "<text:p>After</text:p>" \ + FOOTER expected_tree = etree.fromstring(expected_xml) dct = {"test.cpp": "line1\nline2"} replacer.replace_placeholders(tree, dct) self._compare_trees(tree, expected_tree)