File: update-coverage

package info (click to toggle)
adequate 0.15.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 344 kB
  • sloc: perl: 1,127; python: 351; makefile: 140; sh: 89; ansic: 29
file content (62 lines) | stat: -rwxr-xr-x 2,458 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python3

# Copyright © 2013 Jakub Wilk <jwilk@debian.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
import collections

import apt_pkg

def main():
    base = os.path.join(os.path.dirname(__file__), os.pardir)
    tags = {}
    filename = '{base}/doc/tags.desc'.format(base=base)
    with open(filename, 'rt', encoding='UTF-8') as file:
        for section in apt_pkg.TagFile(file):
            tag = section['tag']
            tags[tag] = 0
    filename = '{base}/tests/testpkg/debian/control'.format(base=base)
    with open(filename, 'rt', encoding='UTF-8') as file:
        for n, section in enumerate(apt_pkg.TagFile(file)):
            if n == 0:
                continue
            description = section['description']
            emitted_tags = frozenset(
                line.split()[0]
                for line in description.splitlines()[1:]
            )
            for tag in emitted_tags:
                tags[tag] += 1
    filename = '{base}/tests/coverage.txt'.format(base=base)
    with open(filename, 'wt', encoding='UTF-8') as file:
        for tag, n in sorted(tags.items()):
            if n == 0:
                checkbox = '[ ]'
            elif n == 1:
                checkbox = '[x]'
            else:
                checkbox = '[{n}]'.format(n=n)
            print('{c} {tag}'.format(c=checkbox, tag=tag), file=file)

if __name__ == '__main__':
    main()

# vim:ts=4 sts=4 sw=4 et