File: all-errors-documented.py

package info (click to toggle)
telepathy-glib 0.24.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 34,628 kB
  • sloc: ansic: 124,643; xml: 34,410; sh: 11,299; python: 3,520; makefile: 1,727; cpp: 16
file content (31 lines) | stat: -rwxr-xr-x 1,036 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
# Check if all the errors have been added to
# docs/reference/telepathy-glib-sections.txt

import os
import sys

import xml.dom.minidom

from libglibcodegen import NS_TP

def check_all_errors_documented(abs_top_srcdir):
    error_path = os.path.join(abs_top_srcdir, 'spec', 'errors.xml')
    sections_path = os.path.join(abs_top_srcdir, 'docs', 'reference',
        'telepathy-glib-sections.txt')
    sections = open(sections_path).readlines()

    dom = xml.dom.minidom.parse(error_path)

    errors = dom.getElementsByTagNameNS(NS_TP, 'errors')[0]
    for error in errors.getElementsByTagNameNS(NS_TP, 'error'):
        nick = error.getAttribute('name').replace(' ', '')
        name = ('TP_ERROR_STR_' +
                error.getAttribute('name').replace('.', '_').replace(' ', '_').upper())

        if '%s\n' % name not in sections:
            print "'%s' is missing in %s" % (name, sections_path)
            sys.exit(1)

if __name__ == '__main__':
    check_all_errors_documented(os.environ['abs_top_srcdir'])