Esempio n. 1
0
def parse_combined_file(file_name):
    f = open(file_name, "r")
    archive_name = "(ERROR)"
    file_name = "(ERROR)"
    license_declared = "(ERROR)"
    comments = "(ERROR)"
    output = False

    for line in f:
        file_info = line.split(";")
        archive_name = file_info[0]  # The name of the archive scanned
        file_name = file_info[1]  # The name of the file scanned
        foss_out = file_info[2].split(",")  # Fossology's output
        ninka_out = file_info[3].split(",")  # Ninka's output

        # If fossology and Ninka throw an error, skip this entry
        if foss_out[0] != "ERROR" and ninka_out[0] != "ERROR":
            result = combined_parser(foss_out, ninka_out)
            license_declared = result[0]
            comments = result[1]
            if not output:
                temp = (archive_name, file_name, license_declared, comments)
                output = [temp]
            else:
                temp = (archive_name, file_name, license_declared, comments)
                output.append(temp)

    return output
Esempio n. 2
0
def parse_combined_file(file_name):
    """
    Parses the unified internal file that parse_output() created and places the
    results in a tuple that can be easily translated to a JSON object for use
    with SPDX 1.2.

    The input format is archive_name;file_name;FOSSology_output;ninka_output

    The output format is (archive_name, file_name, license_concluded, comments)
    """
    f = open(file_name, 'r')
    archive_name = "(ERROR)"
    file_name = "(ERROR)"
    license_concluded = "(ERROR)"
    comments = "(ERROR)"
    output = False

    for line in f:
        file_info = line.split(";")
        archive_name = file_info[0] #The name of the archive scanned
        file_name = file_info[1] #The name of the file scanned
        sha1 = file_info[2] #The SHA-1 checksum
        foss_out = file_info[3].split(",") #FOSSology's output
        ninka_out = file_info[4].split(",") #Ninka's output

        #If FOSSology and Ninka throw an error, skip this entry
        if foss_out[0] != "ERROR" and ninka_out[0] != "ERROR":
            result = combined_parser(foss_out, ninka_out)
            license_concluded = result[0]
            comments = result[1]
            if not output:
                temp = (archive_name, file_name, sha1,
                    license_concluded, comments)
                output = [temp]
            else:
                temp = (archive_name, file_name, sha1,
                    license_concluded, comments)
                output.append(temp)
    
    return output