def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 1, 1), ('CCC', 2, 1), ('DDD', 2, 1), ('EEE', 1, 1), ('FFF', 2, 1), ('GGG', 2, 1), ('HHH', 1, 1), ('III', 2, 1), ('JJJ', 2, 1), ('KKK', 0, 1), ('LLL', 0, 2), ('MMM', 1, 2), ('NNN', 1, 2), ('OOO', 0, 2), ('PPP', 1, 2), ('QQQ', 1, 2), ('RRR', 2, 2), ('SSS', 0, 2), ('TTT', 1, 2), ('UUU', 1, 2), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): p_tags = [ DXB.p_tag(text='AAA', style='style0'), DXB.p_tag( [ DXB.r_tag( [DXB.t_tag('BBB')], # Don't do duplicates rpr=DXB.rpr_tag({'b': None}), ), ], style='style0', ), DXB.p_tag( [ DXB.r_tag( [DXB.t_tag('CCC')], # Overwrite the current style rpr=DXB.rpr_tag({'b': 'false'}), ), ], style='style0', ), ] body = b'' for tag in p_tags: body += tag xml = DXB.xml(body) return xml
def get_xml(self): p_tags = [ DXB.p_tag(text='AAA', style='style0'), DXB.p_tag( [ DXB.r_tag( [DXB.t_tag('BBB')], # Don't do duplicates rpr=DXB.rpr_tag({'b': None}), ), ], style='style0', ), DXB.p_tag( [ DXB.r_tag( [DXB.t_tag('CCC')], # Overwrite the current style rpr=DXB.rpr_tag({'b': 'false'}), ), ], style='style0', ), ] body = '' for tag in p_tags: body += tag xml = DXB.xml(body) return xml
def get_xml(self): body = b'' body += DXB.li(text='AAA', ilvl=0, numId=0) body += DXB.sdt_tag(p_tag=DXB.p_tag(text='BBB')) body += DXB.li(text='CCC', ilvl=0, numId=0) xml = DXB.xml(body) return xml
def get_xml(self): body = '' body += DXB.li(text='AAA', ilvl=0, numId=0) body += DXB.sdt_tag(p_tag=DXB.p_tag(text='BBB')) body += DXB.li(text='CCC', ilvl=0, numId=0) xml = DXB.xml(body) return xml
def get_xml(self): # Make sure it is over 1000 (which is the recursion limit) paragraphs = [DXB.p_tag('%d' % i) for i in range(1000)] cell = DXB.table_cell(paragraphs) row = DXB.table_cell([cell]) table = DXB.table([row]) body = table xml = DXB.xml(body) return xml
def get_xml(self): p_tag = DXB.p_tag(None) # No text run_tags = [p_tag] # The bug is only present in a hyperlink run_tags = [DXB.hyperlink_tag(r_id='rId0', run_tags=run_tags)] body = DXB.p_tag(run_tags) xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ] lis = '' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): delete_tags = DXB.delete_tag(['BBB']) p_tag = DXB.p_tag([delete_tags]) body = DXB.li(text='AAA', ilvl=0, numId=0) body += p_tag body += DXB.li(text='CCC', ilvl=0, numId=0) xml = DXB.xml(body) return xml
def get_xml(self): paragraph = DXB.p_tag('AAA') for _ in range(1000): cell = DXB.table_cell(paragraph) row = DXB.table_cell([cell]) table = DXB.table([row]) body = table xml = DXB.xml(body) return xml
def get_xml(self): li = DXB.li(text='AAA', ilvl=0, numId=1) p_tags = [ DXB.p_tag('BBB'), ] body = li for p_tag in p_tags: body += p_tag xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): r_tag = DXB.r_tag([DXB.t_tag(letter) for letter in 'ABC'], ) p_tag = DXB.p_tag( [r_tag], jc='start', ) body = p_tag xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.p_tag([ DXB.r_tag([DXB.t_tag(None)], ), ], ), ] body = b'' for tag in tags: body += tag return DXB.xml(body)
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', None, 1), # Because why not. ('CCC', 0, 1), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) body = lis xml = DXB.xml(body) return xml
def get_xml(self): drawing = DXB.drawing(height=None, width=None, r_id='rId0') pict = DXB.pict(height=None, width=None, r_id='rId1') tags = [ drawing, pict, ] body = b'' for el in tags: body += el return DXB.xml(body)
def get_xml(self): r_tag = DXB.r_tag( [DXB.t_tag(letter) for letter in 'ABC'], ) p_tag = DXB.p_tag( [r_tag], jc='start', ) body = p_tag xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.li(text='AAA', ilvl=1, numId=1), DXB.li(text='BBB', ilvl=3, numId=1), DXB.li(text='CCC', ilvl=2, numId=1), ] body = '' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.li(text='AAA', ilvl=1, numId=1), DXB.li(text='BBB', ilvl=3, numId=1), DXB.li(text='CCC', ilvl=2, numId=1), ] body = b'' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', None, 1), # Because why not. ('CCC', 0, 1), ] lis = '' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) body = lis xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.p_tag([ DXB.r_tag([DXB.t_tag(r'􀀟')], ), ], ), ] body = b'' for tag in tags: body += tag xml = DXB.xml(body) return xml
def get_xml(self): drawing = DXB.drawing(height=20, width=40, r_id='rId0') pict = DXB.pict(height=21, width=41, r_id='rId1') tags = [ drawing, pict, ] body = b'' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): raise SkipTest( 'Since we are not using PIL, we do not need this test yet.', ) drawing = DXB.drawing('rId0') tags = [ drawing, ] body = b'' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): drawing = DXB.drawing(height=20, width=40, r_id='rId0') pict = DXB.pict(height=21, width=41, r_id='rId1') tags = [ drawing, pict, ] body = '' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 1, 1), ('CCC', 0, 1), ('DDD', 1, 1), ('EEE', 2, 1), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): raise SkipTest( 'Since we are not using PIL, we do not need this test yet.', ) drawing = DXB.drawing('rId0') tags = [ drawing, ] body = '' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.p_tag( [ DXB.r_tag( [DXB.t_tag(None)], ), ], ), ] body = b'' for tag in tags: body += tag return DXB.xml(body)
def get_xml(self): li_text = [ ('AAA', 0, 2), # Because AAA and CCC are part of the same list (same list id) # and BBB is different, these need to be split into three # lists (or lose everything from BBB and after. ('BBB', 0, 1), ('CCC', 0, 2), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): li_text = [ ('AAA', 0, 2), # Because AAA and CCC are part of the same list (same list id) # and BBB is different, these need to be split into three # lists (or lose everything from BBB and after. ('BBB', 0, 1), ('CCC', 0, 2), ] lis = '' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(lis) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 1, 1), ('CCC', 0, 2), ('DDD', 1, 2), ('EEE', 0, 3), ('FFF', 1, 3), ('GGG', 2, 3), ] body = b'' for text, ilvl, numId in li_text: body += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(body) return xml
def get_xml(self): tags = [ DXB.p_tag( [ DXB.r_tag( [DXB.t_tag(None)], ), ], ), ] body = '' for tag in tags: body += tag xml = DXB.xml(body) return xml.encode('utf-8')
def get_xml(self): tags = [ DXB.p_tag( [ DXB.r_tag( [DXB.t_tag(r'􀀟')], ), ], ), ] body = b'' for tag in tags: body += tag xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 1, 1), ('CCC', 0, 2), ('DDD', 1, 2), ('EEE', 0, 3), ('FFF', 1, 3), ('GGG', 2, 3), ] body = '' for text, ilvl, numId in li_text: body += DXB.li(text=text, ilvl=ilvl, numId=numId) xml = DXB.xml(body) return xml
def _build_data( self, path, document_xml=None, rels_dict=None, numbering_dict=None, styles_dict=None, *args, **kwargs): self._test_rels_dict = rels_dict if rels_dict: for value in rels_dict.values(): self._image_data['word/%s' % value] = 'word/%s' % value self.numbering_root = None if numbering_dict is not None: self.numbering_root = parse_xml_from_string( DXB.numbering(numbering_dict), ) self.numbering_dict = numbering_dict # Intentionally not calling super if document_xml is not None: self.root = parse_xml_from_string(document_xml) self.zip_path = '' # This is the standard page width for a word document, Also the page # width that we are looking for in the test. self.page_width = 612 self.styles_dict = styles_dict
def get_xml(self): run_tags = [DXB.r_tag([DXB.t_tag(i)]) for i in 'insert '] insert_tag = DXB.insert_tag(run_tags) run_tags = [DXB.r_tag([DXB.t_tag(i)]) for i in 'smarttag'] smart_tag = DXB.smart_tag(run_tags) run_tags = [insert_tag, smart_tag] body = DXB.p_tag(run_tags) xml = DXB.xml(body) return xml
def get_xml(self): run_tags = [DXB.r_tag([DXB.t_tag(i)]) for i in 'link'] run_tags = [DXB.hyperlink_tag(r_id='rId0', run_tags=run_tags)] run_tags.append(DXB.r_tag([DXB.t_tag('.')])) body = DXB.p_tag(run_tags) xml = DXB.xml(body) return xml
def get_xml(self): run_tags = [] run_tags.append(DXB.r_tag([DXB.t_tag('link')])) run_tags.append(DXB.r_tag([DXB.linebreak()])) run_tags = [DXB.hyperlink_tag(r_id='rId0', run_tags=run_tags)] body = DXB.p_tag(run_tags) xml = DXB.xml(body) return xml
def get_xml(self): run_tags = [DXB.r_tag([DXB.t_tag(i)]) for i in 'BBB'] smart_tag = DXB.smart_tag(run_tags) p_tag = DXB.p_tag([smart_tag]) body = DXB.li(text='AAA', ilvl=0, numId=0) body += p_tag body += DXB.li(text='CCC', ilvl=0, numId=0) xml = DXB.xml(body) return xml
def get_xml(self): p_tags = [ DXB.p_tag(text='AAA', style='style0'), DXB.p_tag(text='BBB', style='style1'), DXB.p_tag(text='CCC', style='style2'), DXB.p_tag(text='DDD', style='style3'), DXB.p_tag(text='EEE', style='style4'), DXB.p_tag(text='GGG', style='style5'), DXB.p_tag(text='HHH', style='garbage'), ] body = '' for tag in p_tags: body += tag xml = DXB.xml(body) return xml
def get_xml(self): p_tags = [ DXB.p_tag(text='AAA', style='style0'), DXB.p_tag(text='BBB', style='style1'), DXB.p_tag(text='CCC', style='style2'), DXB.p_tag(text='DDD', style='style3'), DXB.p_tag(text='EEE', style='style4'), DXB.p_tag(text='GGG', style='style5'), DXB.p_tag(text='HHH', style='garbage'), ] body = b'' for tag in p_tags: body += tag xml = DXB.xml(body) return xml
def _load(self): self.document = WordprocessingDocument(path=None) package = self.document.package document_part = package.create_part( uri='/word/document.xml', ) if self.relationships: for relationship in self.relationships: target_mode = 'Internal' if relationship['external']: target_mode = 'External' target_uri = relationship['target_path'] if 'data' in relationship: full_target_uri = posixpath.join( package.uri, 'word', target_uri, ) package.streams[full_target_uri] = BytesIO( relationship['data'], ) package.create_part(uri=full_target_uri) document_part.create_relationship( target_uri=target_uri, target_mode=target_mode, relationship_type=relationship['relationship_type'], relationship_id=relationship['relationship_id'], ) package.streams[document_part.uri] = BytesIO(self.document_xml) package.create_relationship( target_uri=document_part.uri, target_mode='Internal', relationship_type=MainDocumentPart.relationship_type, ) self.numbering_root = None if self.numbering_dict is not None: self.numbering_root = parse_xml_from_string( DXB.numbering(self.numbering_dict), ) # This is the standard page width for a word document (in points), Also # the page width that we are looking for in the test. self.page_width = 612 self.parse_begin(self.document.main_document_part.root_element)
def get_xml(self): li_text = [ ('BBB', 0, 1), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) cell1 = DXB.table_cell(lis) rows = DXB.table_row([cell1]) table = DXB.table([rows]) lis = b'' lis += DXB.li(text='AAA', ilvl=0, numId=1) lis += table lis += DXB.li(text='CCC', ilvl=0, numId=1) body = lis xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('BBB', 0, 1), ] lis = '' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) cell1 = DXB.table_cell(lis) rows = DXB.table_row([cell1]) table = DXB.table([rows]) lis = '' lis += DXB.li(text='AAA', ilvl=0, numId=1) lis += table lis += DXB.li(text='CCC', ilvl=0, numId=1) body = lis xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 0, 1), ] lis = '' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) els = [ lis, DXB.p_tag('CCC'), DXB.p_tag('DDD'), ] td = '' for el in els: td += el cell1 = DXB.table_cell(td) row = DXB.table_row([cell1]) table = DXB.table([row]) body = table xml = DXB.xml(body) return xml
def get_xml(self): li_text = [ ('AAA', 0, 1), ('BBB', 0, 1), ] lis = b'' for text, ilvl, numId in li_text: lis += DXB.li(text=text, ilvl=ilvl, numId=numId) els = [ lis, DXB.p_tag('CCC'), DXB.p_tag('DDD'), ] td = b'' for el in els: td += el cell1 = DXB.table_cell(td) row = DXB.table_row([cell1]) table = DXB.table([row]) body = table xml = DXB.xml(body) return xml
def get_xml(self): cell1 = DXB.table_cell(paragraph=DXB.p_tag('Blank')) cell2 = DXB.table_cell(paragraph=DXB.p_tag('Row 1')) cell3 = DXB.table_cell(paragraph=DXB.p_tag('Row 2')) cell4 = DXB.table_cell(paragraph=DXB.p_tag('Column 1')) cell5 = DXB.table_cell(paragraph=DXB.p_tag('First')) cell6 = DXB.table_cell(paragraph=DXB.p_tag('Third')) cell7 = DXB.table_cell(paragraph=DXB.p_tag('Column 2')) cell8 = DXB.table_cell(paragraph=DXB.p_tag('Second')) cell9 = DXB.table_cell(paragraph=DXB.p_tag('Fourth')) rows = [ DXB.table_row([cell1, cell4, cell7]), DXB.table_row([cell2, cell5, cell8]), DXB.table_row([cell3, cell6, cell9]) ] table = DXB.table(rows) body = table xml = DXB.xml(body) return xml
def get_xml(self): cell1 = DXB.table_cell(paragraph=DXB.p_tag('DDD')) cell2 = DXB.table_cell(paragraph=DXB.p_tag('FFF')) cell3 = DXB.table_cell(paragraph=DXB.p_tag('EEE')) cell4 = DXB.table_cell(paragraph=DXB.p_tag('GGG')) rows = [DXB.table_row([cell1, cell3]), DXB.table_row([cell2, cell4])] table = DXB.table(rows) tags = [ DXB.li(text='AAA', ilvl=0, numId=1), DXB.p_tag('BBB'), DXB.li(text='CCC', ilvl=0, numId=1), table, DXB.li(text='HHH', ilvl=0, numId=1), ] body = b'' for el in tags: body += el xml = DXB.xml(body) return xml
def get_xml(self): cell = DXB.table_cell(paragraph=DXB.p_tag('BBB')) row = DXB.table_row([cell]) table1 = DXB.table([row]) cell = DXB.table_cell(paragraph=DXB.p_tag('CCC')) row = DXB.table_row([cell]) table2 = DXB.table([row]) tags = [ DXB.li(text='AAA', ilvl=0, numId=1), table1, table2, DXB.li(text='DDD', ilvl=0, numId=1), ] body = b'' for el in tags: body += el xml = DXB.xml(body) return xml