本文整理汇总了Python中pydocx.tests.document_builder.DocxBuilder类的典型用法代码示例。如果您正苦于以下问题:Python DocxBuilder类的具体用法?Python DocxBuilder怎么用?Python DocxBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocxBuilder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_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
开发者ID:Isendir,项目名称:pydocx,代码行数:30,代码来源:test_xml.py
示例2: get_xml
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
开发者ID:AaronWan,项目名称:pydocx,代码行数:30,代码来源:test_xml.py
示例3: get_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)
开发者ID:07pack,项目名称:pydocx,代码行数:15,代码来源:test_xml.py
示例4: _build_data
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
开发者ID:Isendir,项目名称:pydocx,代码行数:28,代码来源:__init__.py
示例5: _load
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)
开发者ID:07pack,项目名称:pydocx,代码行数:48,代码来源:__init__.py
注:本文中的pydocx.tests.document_builder.DocxBuilder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论