本文整理匯總了Python中theme.Theme.set_from方法的典型用法代碼示例。如果您正苦於以下問題:Python Theme.set_from方法的具體用法?Python Theme.set_from怎麽用?Python Theme.set_from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類theme.Theme
的用法示例。
在下文中一共展示了Theme.set_from方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse
# 需要導入模塊: from theme import Theme [as 別名]
# 或者: from theme.Theme import set_from [as 別名]
def parse(self, config, source):
"""Parse presentation from source stream.
Parameters
----------
config : MatisseConfig
MaTiSSe configuration
source: str
"""
complete_source = self.parser.includes(source=source)
self.__get_metadata(source=complete_source)
self.__get_theme(source=complete_source)
new_theme = Theme()
new_theme.set_from(other=self.theme)
tokens = self.parser.tokenize(source=complete_source)
self.__check_bad_sectioning(tokens=tokens)
chapters_number = 0
sections_number = 0
subsections_number = 0
slides_number = 0
titlepage_inserted = False
for chap in tokens['chapters']:
chapters_number += 1
slide_local_numbers = [0, 0, 0]
if chap['match'].group('expr'):
chapter = Chapter(number=chapters_number, title=chap['match'].group('expr'))
else:
chapter = Chapter(number=chapters_number, title='')
for sec in tokens['sections']:
if sec['start'] >= chap['start'] and sec['start'] <= chap['end_next']:
sections_number += 1
slide_local_numbers[1] = 0
slide_local_numbers[2] = 0
section = Section(number=sections_number, title=sec['match'].group('expr'))
for subsec in tokens['subsections']:
if subsec['start'] >= sec['start'] and subsec['start'] <= sec['end_next']:
subsections_number += 1
slide_local_numbers[2] = 0
subsection = Subsection(number=subsections_number, title=subsec['match'].group('expr'))
for sld in tokens['slides']:
if '$titlepage' in sld['match'].group().lower() and not titlepage_inserted:
slide = Slide(number=0,
title='titlepage',
contents=complete_source[sld['end']:sld['end_next']])
slide.get_overtheme(parser=self.parser)
if slide.overtheme.copy_from_theme is not None and slide.overtheme.copy_from_theme:
slide.overtheme.copy_from(other=self.theme)
self.position.update_position(presentation_theme=self.theme, overtheme=slide.overtheme)
slide.set_position(position=self.position.position)
subsection.add_slide(slide=slide)
titlepage_inserted = True
else:
if sld['start'] >= subsec['start'] and sld['start'] <= subsec['end_next']:
slide_local_numbers[0] += 1
slide_local_numbers[1] += 1
slide_local_numbers[2] += 1
if slide_local_numbers[0] == 1 and config.toc_at_chap_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_chap_beginning) + ']'))
if slide_local_numbers[1] == 1 and config.toc_at_sec_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_sec_beginning) + ']'))
if slide_local_numbers[2] == 1 and config.toc_at_subsec_beginning is not None:
slides_number += 1
self.position.update_position(presentation_theme=self.theme)
subsection.add_slide(slide=Slide(number=slides_number,
position=self.position.position,
title='Table of Contents',
contents='$toc[depth:' + str(config.toc_at_subsec_beginning) + ']'))
slides_number += 1
slide = Slide(number=slides_number,
title=sld['match'].group('expr'),
contents=complete_source[sld['end']:sld['end_next']])
slide.get_overtheme(parser=self.parser)
if slide.overtheme.copy_from_theme is not None and slide.overtheme.copy_from_theme:
slide.overtheme.copy_from(other=self.theme)
self.position.update_position(presentation_theme=self.theme, overtheme=slide.overtheme)
slide.set_position(position=self.position.position)
subsection.add_slide(slide=slide)
section.add_subsection(subsection=subsection)
chapter.add_section(section=section)
self.__add_chapter(chapter=chapter)
self.metadata['total_slides_number'].update_value(value=str(Subsection.slides_number))