Exemplo n.º 1
0
 def parse(self):
     regex = '== (?P<title>.+) =='
     pattern = re.compile(regex, re.UNICODE)
     match = pattern.match(self.heading)
     if match:
         self.set_property('einsatz_slug', match.groupdict()['title'])
     else:
         raise ParsingError('Cannot parse log page.')
     for level3block in Chopper(self.text, [
             Level3Block,
     ],
                                filler_blocks=True,
                                include_tags=True):
         # It's allowed to have some unknown text before the first
         # level3 block.
         if isinstance(level3block, FillerBlock):
             section = FillerSection(text=level3block.text, parent=self)
             section = section.parse()
             self.top_section = section
         else:
             section = AlertSection(text=level3block.text,
                                    parent=self,
                                    heading=level3block.start_tag)
             section = section.parse()
             if section.get_property('alert_slug') in self.alert_sections:
                 raise ParsingError('Two EinsatzSections with same title.')
             self.alert_sections[section.get_property(
                 'alert_slug')] = section
         self.children.append(section)
     return self
Exemplo n.º 2
0
 def parse(self):
     self.einsatz_sections = {}
     for level2block in Chopper(self.text, [Level2Block,],
                                filler_blocks=True, include_tags=True):
         # It's allowed to have some unknown text before the first
         # level2 block.
         if isinstance(level2block, FillerBlock):
             section = FillerSection(text=level2block.text, parent=self)
             section = section.parse()
         else:
             section = EinsatzSection(text=level2block.text, parent=self, heading=level2block.start_tag)
             section = section.parse()
             if section.get_property('einsatz_slug') in self.einsatz_sections:
                 raise ParsingError('EinsatzSection title is not unique.')
             self.einsatz_sections[section.get_property('einsatz_slug')] = section
         self.children.append(section)
     return self
Exemplo n.º 3
0
 def parse(self):
     self.einsatz_sections = {}
     for level2block in Chopper(self.text, [
             Level2Block,
     ],
                                filler_blocks=True,
                                include_tags=True):
         # It's allowed to have some unknown text before the first
         # level2 block.
         if isinstance(level2block, FillerBlock):
             section = FillerSection(text=level2block.text, parent=self)
             section = section.parse()
         else:
             section = EinsatzSection(text=level2block.text,
                                      parent=self,
                                      heading=level2block.start_tag)
             section = section.parse()
             if section.get_property(
                     'einsatz_slug') in self.einsatz_sections:
                 raise ParsingError('EinsatzSection title is not unique.')
             self.einsatz_sections[section.get_property(
                 'einsatz_slug')] = section
         self.children.append(section)
     return self
Exemplo n.º 4
0
 def parse(self):
     regex = '== (?P<title>.+) =='
     pattern = re.compile(regex, re.UNICODE)
     match = pattern.match(self.heading)
     if match:
         self.set_property('einsatz_slug', match.groupdict()['title'])
     else:
         raise ParsingError('Cannot parse log page.')
     for level3block in Chopper(self.text, [Level3Block,],
                                filler_blocks=True, include_tags=True):
         # It's allowed to have some unknown text before the first
         # level3 block.
         if isinstance(level3block, FillerBlock):
             section = FillerSection(text=level3block.text, parent=self)
             section = section.parse()
             self.top_section = section
         else:
             section = AlertSection(text=level3block.text, parent=self, heading=level3block.start_tag)
             section = section.parse()
             if section.get_property('alert_slug') in self.alert_sections:
                 raise ParsingError('Two EinsatzSections with same title.')
             self.alert_sections[section.get_property('alert_slug')] = section
         self.children.append(section)
     return self