File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # vim:fenc=utf-8
4
+ #
5
+ # Copyright © 2019 Shlomi Fish <[email protected] >
6
+ #
7
+ # Distributed under terms of the MIT license.
8
+
9
+ # import re
10
+ import unittest
11
+
12
+ import html_unit_test
13
+ from html_unit_test import ns
14
+
15
+
16
+ class MyTests (html_unit_test .TestCase ):
17
+ def test_initial_docbook (self ):
18
+ input_fn = './FAQ.docbook5.xml'
19
+ doc = self .doc (input_fn , filetype = 'docbook5' )
20
+ sections = doc .xpath ('//db:section' )
21
+ id_attr = '{xml}id' .format (xml = ("{" + ns ['xml' ] + "}" ))
22
+
23
+ def _process_sections ():
24
+ output_text = ""
25
+ while len (sections .xpath_results ):
26
+ section = sections .xpath_results .pop (0 )
27
+ id2 = section .get (id_attr )
28
+ title_xpath = './db:title/text()'
29
+ docbook5_title_list = section .xpath (
30
+ title_xpath , namespaces = ns
31
+ )
32
+ docbook5_title = docbook5_title_list [0 ]
33
+ output_text += "* [{}](#{})\n " .format (docbook5_title , id2 )
34
+ print (output_text )
35
+ return output_text
36
+
37
+ _process_sections ()
38
+ if 0 :
39
+ for section in sections .xpath_results :
40
+ print (section .get (id_attr ))
41
+
42
+
43
+ if __name__ == '__main__' :
44
+ from pycotap import TAPTestRunner
45
+ suite = unittest .TestLoader ().loadTestsFromTestCase (MyTests )
46
+ TAPTestRunner ().run (suite )
You can’t perform that action at this time.
0 commit comments