#!/usr/bin/python3 # Copyright © 2013 Jakub Wilk # # 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