コード例 #1
0
ファイル: presentation.py プロジェクト: nunb/MaTiSSe
    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))
コード例 #2
0
 def reset(cls):
     """Reset to default state."""
     cls.subsections_number = 0
     Subsection.reset()
     return
コード例 #3
0
ファイル: presentation.py プロジェクト: szaghi/MaTiSSe
  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))
コード例 #4
0
ファイル: section.py プロジェクト: nunb/MaTiSSe
 def reset(cls):
   """Reset to default state."""
   cls.subsections_number = 0
   Subsection.reset()
   return