コード例 #1
0
def excludeJhoveProperties(fits):
    """Exclude <properties> from <fits><toolOutput><tool name="Jhove" version="1.5"><repInfo> because that field contains unnecessary excess data and the key data are covered by output from other FITS tools."""
    formatValidation = None

    tools = getTagged(getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Jhove":
            formatValidation = tool
            break
    if formatValidation == None:
        return fits
    repInfo = getTagged(formatValidation, "repInfo")[0]
    properties = getTagged(repInfo, "properties")

    if len(properties):
        repInfo.remove(properties[0])
    return fits
コード例 #2
0
def excludeJhoveProperties(fits):
    """Exclude <properties> from <fits><toolOutput><tool name="Jhove" version="1.5"><repInfo> because that field contains unnecessary excess data and the key data are covered by output from other FITS tools."""
    formatValidation = None

    tools = getTagged(
        getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Jhove":
            formatValidation = tool
            break
    if formatValidation == None:
        return fits
    repInfo = getTagged(formatValidation, "repInfo")[0]
    properties = getTagged(repInfo, "properties")

    if len(properties):
        repInfo.remove(properties[0])
    return fits
コード例 #3
0
ファイル: fits.py プロジェクト: verifyaccess/archivematica
def exclude_jhove_properties(fits):
    """
    Exclude <properties> from "/fits/toolOutput/tool[name=Jhove]/repInfo"
    because that field contains unnecessary excess data and the key data are
    covered by output from other FITS tools.
    """
    format_validation = None
    tools = getTagged(getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Jhove":
            format_validation = tool
            break
    if format_validation is None:
        return fits
    repInfo = getTagged(format_validation, "repInfo")[0]
    properties = getTagged(repInfo, "properties")
    if len(properties):
        repInfo.remove(properties[0])
    return fits
コード例 #4
0
def formatValidationFITSAssist(fits):
    global exitCode
    prefix = ""
    formatValidation = None

    tools = getTagged(
        getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Jhove":
            formatValidation = tool
            break
    if formatValidation == None:
        print >> sys.stderr, "No format validation tool output (Jhove)."
        exitCode += 6
        raise Exception('Jhove', 'not present')

    repInfo = getTagged(formatValidation, "repInfo")[0]
    #<eventDetail>program="DROID"; version="3.0"</eventDetail>
    eventDetailText =   "program=\"" + formatValidation.get("name") \
                        + "\"; version=\"" + formatValidation.get("version") + "\""

    #<status>Well-Formed and valid</status>
    status = getTagged(repInfo, prefix + "status")[0].text
    eventOutcomeText = "fail"
    if status == "Well-Formed and valid":
        eventOutcomeText = "pass"

    #<eventOutcomeDetailNote> format="Windows Bitmap"; version="3.0"; result="Well-formed and valid" </eventOutcomeDetailNote>
    format = getTagged(repInfo, prefix + "format")[0].text
    versionXML = getTagged(repInfo, prefix + "version")
    version = ""
    if len(versionXML):
        version = versionXML[0].text
    eventOutcomeDetailNote = "format=\"" + format
    if version:
        eventOutcomeDetailNote += "\"; version=\"" + version
    eventOutcomeDetailNote += "\"; result=\"" + status + "\""

    return tuple([eventDetailText, eventOutcomeText, eventOutcomeDetailNote
                  ])  #tuple([1, 2, 3]) returns (1, 2, 3).
コード例 #5
0
def formatValidationFITSAssist(fits):
    global exitCode
    prefix = ""
    formatValidation = None

    tools = getTagged(getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Jhove":
            formatValidation = tool
            break
    if formatValidation == None:
        print >>sys.stderr, "No format validation tool output (Jhove)."
        exitCode += 6
        raise Exception('Jhove', 'not present')

    repInfo = getTagged(formatValidation, "repInfo")[0]
    #<eventDetail>program="DROID"; version="3.0"</eventDetail>
    eventDetailText =   "program=\"" + formatValidation.get("name") \
                        + "\"; version=\"" + formatValidation.get("version") + "\""


    #<status>Well-Formed and valid</status>
    status = getTagged( repInfo, prefix + "status")[0].text
    eventOutcomeText = "fail"
    if status == "Well-Formed and valid":
        eventOutcomeText = "pass"

    #<eventOutcomeDetailNote> format="Windows Bitmap"; version="3.0"; result="Well-formed and valid" </eventOutcomeDetailNote>
    format = getTagged(repInfo, prefix + "format")[0].text
    versionXML = getTagged(repInfo, prefix + "version")
    version = ""
    if len(versionXML):
        version = versionXML[0].text
    eventOutcomeDetailNote = "format=\"" + format
    if version:
        eventOutcomeDetailNote += "\"; version=\"" + version
    eventOutcomeDetailNote += "\"; result=\"" + status + "\""

    return tuple([eventDetailText, eventOutcomeText, eventOutcomeDetailNote]) #tuple([1, 2, 3]) returns (1, 2, 3).
コード例 #6
0
def formatIdentificationFITSAssist(fits, fileUUID):
    prefix = "{http://www.nationalarchives.gov.uk/pronom/FileCollection}"
    formatIdentification = None

    tools = getTagged(getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Droid":
            formatIdentification = tool
            break
    #<eventDetail>program="DROID"; version="3.0"</eventDetail>
    eventDetailText =   "program=\"" + formatIdentification.get("name") \
                        + "\"; version=\"" + formatIdentification.get("version") + "\""

    #<eventOutcome>positive</eventOutcome>

    fileCollection = getTagged(formatIdentification, prefix + "FileCollection")[0]
    IdentificationFile = getTagged(fileCollection, prefix + "IdentificationFile")[0]
    eventOutcomeText =  IdentificationFile.get( "IdentQuality")

    #<eventOutcomeDetailNote>fmt/116</eventOutcomeDetailNote>
    #<FileFormatHit />
    fileFormatHits = getTagged(IdentificationFile, prefix + "FileFormatHit")
    eventOutcomeDetailNotes = []
    eventOutcomeDetailNote = ""
    for fileFormatHit in fileFormatHits:
        format = etree.Element("format")
        if len(fileFormatHit):
            formatIDSQL = {"fileUUID":fileUUID, \
                        "formatName":"", \
                        "formatVersion":"", \
                        "formatRegistryName":"PRONOM", \
                        "formatRegistryKey":""}
            eventOutcomeDetailNote = getTagged(fileFormatHit, prefix + "PUID")[0].text

            #formatDesignation = etree.SubElement(format, "formatDesignation")
            formatName = getTagged(fileFormatHit, prefix + "Name")
            formatVersion = getTagged(fileFormatHit, prefix + "Version")


            if len(formatName):
                #etree.SubElement(formatDesignation, "formatName").text = formatName[0].text
                formatIDSQL["formatName"] = formatName[0].text
            if len(formatVersion):
                #etree.SubElement(formatDesignation, "formatVersion").text = formatVersion[0].text
                formatIDSQL["formatVersion"] = formatVersion[0].text
            formatRegistry = etree.SubElement(format, "formatRegistry")

            PUID = getTagged(fileFormatHit, prefix + "PUID")
            if len(PUID):
                #etree.SubElement(formatRegistry, "formatRegistryName").text = "PRONOM"
                #etree.SubElement(formatRegistry, "formatRegistryKey").text = PUID[0].text
                formatIDSQL["formatRegistryKey"] = PUID[0].text
            formats.append(format)
            print formatIDSQL
            insertIntoFilesIDs(fileUUID=fileUUID, \
                               formatName=formatIDSQL["formatName"], \
                               formatVersion=formatIDSQL["formatVersion"], \
                               formatRegistryName=formatIDSQL["formatRegistryName"], \
                               formatRegistryKey=formatIDSQL["formatRegistryKey"])
        else:
            eventOutcomeDetailNote = "No Matching Format Found"
            formatDesignation = etree.SubElement(format, "formatDesignation")
            etree.SubElement(formatDesignation, "formatName").text = "Unknown"
            formats.append(format)
        eventOutcomeDetailNotes.append(eventOutcomeDetailNote)
    return tuple([eventDetailText, eventOutcomeText, eventOutcomeDetailNotes]) #tuple([1, 2, 3]) returns (1, 2, 3).
コード例 #7
0
def formatIdentificationFITSAssist(fits, fileUUID):
    prefix = "{http://www.nationalarchives.gov.uk/pronom/FileCollection}"
    formatIdentification = None

    tools = getTagged(
        getTagged(fits, FITSNS + "toolOutput")[0], FITSNS + "tool")
    for tool in tools:
        if tool.get("name") == "Droid":
            formatIdentification = tool
            break
    #<eventDetail>program="DROID"; version="3.0"</eventDetail>
    eventDetailText =   "program=\"" + formatIdentification.get("name") \
                        + "\"; version=\"" + formatIdentification.get("version") + "\""

    #<eventOutcome>positive</eventOutcome>

    fileCollection = getTagged(formatIdentification,
                               prefix + "FileCollection")[0]
    IdentificationFile = getTagged(fileCollection,
                                   prefix + "IdentificationFile")[0]
    eventOutcomeText = IdentificationFile.get("IdentQuality")

    #<eventOutcomeDetailNote>fmt/116</eventOutcomeDetailNote>
    #<FileFormatHit />
    fileFormatHits = getTagged(IdentificationFile, prefix + "FileFormatHit")
    eventOutcomeDetailNotes = []
    eventOutcomeDetailNote = ""
    for fileFormatHit in fileFormatHits:
        format = etree.Element("format")
        if len(fileFormatHit):
            formatIDSQL = {"fileUUID":fileUUID, \
                        "formatName":"", \
                        "formatVersion":"", \
                        "formatRegistryName":"PRONOM", \
                        "formatRegistryKey":""}
            eventOutcomeDetailNote = getTagged(fileFormatHit,
                                               prefix + "PUID")[0].text

            #formatDesignation = etree.SubElement(format, "formatDesignation")
            formatName = getTagged(fileFormatHit, prefix + "Name")
            formatVersion = getTagged(fileFormatHit, prefix + "Version")

            if len(formatName):
                #etree.SubElement(formatDesignation, "formatName").text = formatName[0].text
                formatIDSQL["formatName"] = formatName[0].text
            if len(formatVersion):
                #etree.SubElement(formatDesignation, "formatVersion").text = formatVersion[0].text
                formatIDSQL["formatVersion"] = formatVersion[0].text
            formatRegistry = etree.SubElement(format, "formatRegistry")

            PUID = getTagged(fileFormatHit, prefix + "PUID")
            if len(PUID):
                #etree.SubElement(formatRegistry, "formatRegistryName").text = "PRONOM"
                #etree.SubElement(formatRegistry, "formatRegistryKey").text = PUID[0].text
                formatIDSQL["formatRegistryKey"] = PUID[0].text
            formats.append(format)
            print formatIDSQL
            insertIntoFilesIDs(fileUUID=fileUUID, \
                               formatName=formatIDSQL["formatName"], \
                               formatVersion=formatIDSQL["formatVersion"], \
                               formatRegistryName=formatIDSQL["formatRegistryName"], \
                               formatRegistryKey=formatIDSQL["formatRegistryKey"])
        else:
            eventOutcomeDetailNote = "No Matching Format Found"
            formatDesignation = etree.SubElement(format, "formatDesignation")
            etree.SubElement(formatDesignation, "formatName").text = "Unknown"
            formats.append(format)
        eventOutcomeDetailNotes.append(eventOutcomeDetailNote)
    return tuple([eventDetailText, eventOutcomeText, eventOutcomeDetailNotes
                  ])  #tuple([1, 2, 3]) returns (1, 2, 3).