| 1 |
#!/usr/bin/python3 |
| 2 |
|
| 3 |
# Copyright © 2013 Jakub Wilk <[email protected]> |
| 4 |
# |
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
# of this software and associated documentation files (the “Software”), to deal |
| 7 |
# in the Software without restriction, including without limitation the rights |
| 8 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
# copies of the Software, and to permit persons to whom the Software is |
| 10 |
# furnished to do so, subject to the following conditions: |
| 11 |
# |
| 12 |
# The above copyright notice and this permission notice shall be included in |
| 13 |
# all copies or substantial portions of the Software. |
| 14 |
# |
| 15 |
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
# SOFTWARE. |
| 22 |
|
| 23 |
import os |
| 24 |
import collections |
| 25 |
|
| 26 |
import apt_pkg |
| 27 |
|
| 28 |
def main(): |
| 29 |
base = os.path.join(os.path.dirname(__file__), os.pardir) |
| 30 |
# TODO: get this from --list-tags output or tags.desc |
| 31 |
tags = { |
| 32 |
"bin-or-sbin-binary-requires-usr-lib-library": 0, |
| 33 |
"broken-binfmt-detector": 0, |
| 34 |
"broken-binfmt-interpreter": 0, |
| 35 |
"broken-symlink": 0, |
| 36 |
"incompatible-licenses": 0, |
| 37 |
"invalid-dbus-user-or-group": 0, |
| 38 |
"invalid-systemd-user-or-group": 0, |
| 39 |
"invalid-sysvinit-user-or-group": 0, |
| 40 |
"ldd-failure": 0, |
| 41 |
"library-not-found": 0, |
| 42 |
"missing-alternative": 0, |
| 43 |
"missing-copyright-file": 0, |
| 44 |
"missing-pkgconfig-dependency": 0, |
| 45 |
"missing-symbol-version-information": 0, |
| 46 |
"obsolete-conffile": 0, |
| 47 |
"program-name-collision": 0, |
| 48 |
"py-file-not-bytecompiled": 0, |
| 49 |
"pyshared-file-not-bytecompiled": 0, |
| 50 |
"symbol-size-mismatch": 0, |
| 51 |
"undefined-symbol": 0, |
| 52 |
} |
| 53 |
|
| 54 |
filename = '{base}/tests/testpkg/debian/control.in'.format(base=base) |
| 55 |
with open(filename, 'rt', encoding='UTF-8') as file: |
| 56 |
for n, section in enumerate(apt_pkg.TagFile(file)): |
| 57 |
if n == 0: |
| 58 |
continue |
| 59 |
description = section['description'] |
| 60 |
emitted_tags = frozenset( |
| 61 |
line.split()[0] |
| 62 |
for line in description.splitlines()[1:] |
| 63 |
) |
| 64 |
for tag in emitted_tags: |
| 65 |
tags[tag] += 1 |
| 66 |
filename = '{base}/tests/coverage.txt'.format(base=base) |
| 67 |
with open(filename, 'wt', encoding='UTF-8') as file: |
| 68 |
for tag, n in sorted(tags.items()): |
| 69 |
if n == 0: |
| 70 |
checkbox = '[ ]' |
| 71 |
elif n == 1: |
| 72 |
checkbox = '[x]' |
| 73 |
else: |
| 74 |
checkbox = '[{n}]'.format(n=n) |
| 75 |
print('{c} {tag}'.format(c=checkbox, tag=tag), file=file) |
| 76 |
|
| 77 |
if __name__ == '__main__': |
| 78 |
main() |
| 79 |
|
| 80 |
# vim:ts=4 sts=4 sw=4 et |