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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#!/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)
# TODO: get this from --list-tags output or tags.desc
tags = {
"bin-or-sbin-binary-requires-usr-lib-library": 0,
"broken-binfmt-detector": 0,
"broken-binfmt-interpreter": 0,
"broken-symlink": 0,
"incompatible-licenses": 0,
"invalid-dbus-user-or-group": 0,
"invalid-systemd-user-or-group": 0,
"invalid-sysvinit-user-or-group": 0,
"ldd-failure": 0,
"library-not-found": 0,
"missing-alternative": 0,
"missing-copyright-file": 0,
"missing-pkgconfig-dependency": 0,
"missing-symbol-version-information": 0,
"obsolete-conffile": 0,
"program-name-collision": 0,
"py-file-not-bytecompiled": 0,
"pyshared-file-not-bytecompiled": 0,
"symbol-size-mismatch": 0,
"undefined-symbol": 0,
}
filename = '{base}/tests/testpkg/debian/control.in'.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
|