def set_run_text(run: Element, text: str): dom = run.ownerDocument if run_contains_text(run): text_element = run.getElementsByTagNameNS(_namespaces['w'], 't')[0] set_text(text_element, text) else: text_element = dom.createElementNS(_namespaces['w'], 'w:t') set_text(text_element, text) run.appendChild(text_element)
def clear_run_text(run: Element): if run_contains_text(run): text_element = run.getElementsByTagNameNS(_namespaces['w'], 't')[0] set_text(text_element, '')