#!/usr/bin/python import apt c=apt.Cache() filter_function=lambda pc: pc.section.startswith("contrib") or pc.section.startswith("non-free") pl=filter(filter_function, map(lambda x: c[x].candidate, c.keys())) spl_set=set(map(lambda p: p.source_name, pl)) print '\n'.join(sorted(spl_set))