<s> """<STR_LIT>""" <EOL> from . . ns import qn <EOL> from . . simpletypes import ST_BrClear , ST_BrType <EOL> from . . xmlchemy import ( <EOL> BaseOxmlElement , OptionalAttribute , ZeroOrMore , ZeroOrOne <EOL> ) <EOL> class CT_Br ( BaseOxmlElement ) : <EOL> """<STR_LIT>""" <EOL> type = OptionalAttribute ( '<STR_LIT>' , ST_BrType ) <EOL> clear = OptionalAttribute ( '<STR_LIT>' , ST_BrClear ) <EOL> class CT_R ( BaseOxmlElement ) : <EOL> """<STR_LIT>""" <EOL> rPr = ZeroOrOne ( '<STR_LIT>' ) <EOL> t = ZeroOrMore ( '<STR_LIT>' ) <EOL> br = ZeroOrMore ( '<STR_LIT>' ) <EOL> cr = ZeroOrMore ( '<STR_LIT>' ) <EOL> tab = ZeroOrMore ( '<STR_LIT>' ) <EOL> drawing = ZeroOrMore ( '<STR_LIT>' ) <EOL> def _insert_rPr ( self , rPr ) : <EOL> self . insert ( <NUM_LIT:0> , rPr ) <EOL> return rPr <EOL> def add_t ( self , text ) : <EOL> """<STR_LIT>""" <EOL> t = self . _add_t ( text = text ) <EOL> if len ( text . strip ( ) ) < len ( text ) : <EOL> t . set ( qn ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> return t <EOL> def add_drawing ( self , inline_or_anchor ) : <EOL> """<STR_LIT>""" <EOL> drawing = self . _add_drawing ( ) <EOL> drawing . append ( inline_or_anchor ) <EOL> return drawing <EOL> def clear_content ( self ) : <EOL> """<STR_LIT>""" <EOL> content_child_elms = self [ <NUM_LIT:1> : ] if self . rPr is not None else self [ : ] <EOL> for child in content_child_elms : <EOL> self . remove ( child ) <EOL> @ property <EOL> def style ( self ) : <EOL> """<STR_LIT>""" <EOL> rPr = self . rPr <EOL> if rPr is None : <EOL> return None <EOL> return rPr . style <EOL> @ style . setter <EOL> def style ( self , style ) : <EOL> """<STR_LIT>""" <EOL> rPr = self . get_or_add_rPr ( ) <EOL> rPr . style = style <EOL> @ property <EOL> def text ( self ) : <EOL> """<STR_LIT>""" <EOL> text = '<STR_LIT>' <EOL> for child in self : <EOL> if child . tag == qn ( '<STR_LIT>' ) : <EOL> t_text = child . text <EOL> text += t_text if t_text is not None else '<STR_LIT>' <EOL> elif child . tag == qn ( '<STR_LIT>' ) : <EOL> text += '<STR_LIT:\t>' <EOL> elif child . tag in ( qn ( '<STR_LIT>' ) , qn ( '<STR_LIT>' ) ) : <EOL> text += '<STR_LIT:\n>' <EOL> return text <EOL> @ text . setter <EOL> def text ( self , text ) : <EOL> self . clear_content ( ) <EOL> _RunContentAppender . append_to_run_from_text ( self , text ) <EOL> class CT_Text ( BaseOxmlElement ) : <EOL> """<STR_LIT>""" <EOL> class _RunContentAppender ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , r ) : <EOL> self . _r = r <EOL> self . _bfr = [ ] <EOL> @ classmethod <EOL> def append_to_run_from_text ( cls , r , text ) : <EOL> """<STR_LIT>""" <EOL> appender = cls ( r ) <EOL> appender . add_text ( text ) <EOL> def add_text ( self , text ) : <EOL> """<STR_LIT>""" <EOL> for char in text : <EOL> self . add_char ( char ) <EOL> self . flush ( ) <EOL> def add_char ( self , char ) : <EOL> """<STR_LIT>""" <EOL> if char == '<STR_LIT:\t>' : <EOL> self . flush ( ) <EOL> self . _r . add_tab ( ) <EOL> elif char in '<STR_LIT:\r\n>' : <EOL> self . flush ( ) <EOL> self . _r . add_br ( ) <EOL> else : <EOL> self . _bfr . append ( char ) <EOL> def flush ( self ) : <EOL> text = '<STR_LIT>' . join ( self . _bfr ) <EOL> if text : <EOL> self . _r . add_t ( text ) <EOL> del self . _bfr [ : ] </s>
