Exemplo n.º 1
0
def get_licenses_from_deb_copyright(deb_copyright):
    '''
    Given the debian copyright text,
    1. parse each copyright text
    2. filter out all the available licenses
    3. returns a list of unique licenses found inside
    the copyright text
    '''
    collected_paragraphs = list()
    pkg_licenses = set()
    for paragraph in iter(debcon.get_paragraphs_data(deb_copyright)):
        if 'license' in paragraph:
            cp = debut_copyright.CopyrightLicenseParagraph.from_dict(paragraph)
            collected_paragraphs.append(cp)

    deb_pkg_data = debut_copyright.DebianCopyright(
        collected_paragraphs).to_dict()
    for paragraph in deb_pkg_data.get("paragraphs"):
        pkg_license = paragraph.get("license")
        if not pkg_license.startswith("*"):
            pkg_license = pkg_license.split("\n")[0]
            if pkg_license:
                pkg_licenses.add(pkg_license)

    return list(pkg_licenses)
Exemplo n.º 2
0
 def from_text(cls, text):
     paragraphs = iter(debcon.get_paragraphs_data(text))
     return cls._from_paragraph_data(paragraphs)