Exemplo n.º 1
0
    def test_outdent_parse(self):
        text = "\n".join(
            [
                SECTION1,
                LEVEL0,
                LEVEL0 + SIGNATURE,
                LEVEL1,
                LEVEL1 + SIGNATURE,
                LEVEL2 + SIGNATURE,
                OUTDENT + LEVEL0 + SIGNATURE
            ]
        )

        output = tpp.parse(text)

        self.assertTrue(verify(output), error_msg(output))
        self.assertEqual(len(output['sections']), 1)
        self.assertEqual(len(output['sections'][0]['comments']), 1)
        self.assertEqual(len(output['sections'][0]['comments'][0]['comments']), 1)
        self.assertEqual(len(output['sections'][0]
                                   ['comments'][0]
                                   ['comments'][0]
                                   ['comments']), 1)
        self.assertEqual(len(output['sections'][0]
                                   ['comments'][0]
                                   ['comments'][0]
                                   ['comments'][0]
                                   ['comments']), 1)
 def __init__(self, files, warn = False):
   
   self.talk_entries = list()
   self.failed_files = list()
   
   for file in files:
     with open(file, "r") as f:
       text = f.read()
       try:
         parsed = talkpageparser.parse(text)
         self.talk_entries.append(self.extract_sections(parsed))
       except:
         self.failed_files.append(file)
   if warn is True:
     if len(self.failed_files) > 0:
       warnings.warn("Some files failed to be read and parsed. See the failed_files list in the talk_collection object")
Exemplo n.º 3
0
    def test_multi_sections(self):
        text = "\n".join(
            [
                SECTION1,
                LEVEL0,
                LEVEL0 + SIGNATURE,
                SECTION1,
                LEVEL0,
                LEVEL0 + SIGNATURE,
            ]
        )

        output = tpp.parse(text)

        self.assertTrue(verify(output), error_msg(output))
        self.assertEqual(len(output['sections']), 2)
        self.assertEqual(len(output['sections'][0]['comments']), 1)
        self.assertEqual(len(output['sections'][1]['comments']), 1)