def _get_pkg_license(pkg):
    licenses = set()
    cpr = "/usr/share/doc/{0}/copyright".format(pkg)
    if os.path.exists(cpr):
        for line in open(cpr).read().split(os.linesep):
            if line.startswith("License:"):
                licenses.add(line.split(":", 1)[1].strip())

    return ", ".join(sorted(licenses))
Try to get a license from the package.
dataset/ETHPy150Open saltstack/salt/salt/modules/dpkg.py/_get_pkg_license