Skip to content

Commit

Permalink
CR changes and updated DROID XML
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Nov 5, 2023
1 parent f2f643d commit a8c5b49
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
13 changes: 7 additions & 6 deletions cmd/roy/data/DROID_SignatureFile_V114.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS FILE WILL BE REPLACED BEFORE MERGE -->
<FFSignatureFile DateCreated="2023-08-18T15:27:49" Version="114" xmlns="http://www.nationalarchives.gov.uk/pronom/SignatureFile">
<InternalSignatureCollection>
<InternalSignature ID="9" Specificity="Specific">
Expand Down Expand Up @@ -52744,7 +52745,7 @@
PUID="fmt/9" Version="5"/>
<FileFormat ID="612" Name="Tagged Image File Format"
PUID="fmt/10" Version="6"/>
<FileFormat ID="613" MIMEType="application/pdf"
<FileFormat FormatType="Page Description" ID="613" MIMEType="application/pdf"
Name="Acrobat PDF 1.0 - Portable Document Format"
PUID="fmt/14" Version="1.0">
<InternalSignatureID>123</InternalSignatureID>
Expand Down Expand Up @@ -52792,7 +52793,7 @@
<HasPriorityOverFileFormatID>687</HasPriorityOverFileFormatID>
<HasPriorityOverFileFormatID>869</HasPriorityOverFileFormatID>
</FileFormat>
<FileFormat ID="619" MIMEType="image/gif"
<FileFormat FormatType="Image (Raster)" ID="619" MIMEType="image/gif"
Name="Graphics Interchange Format" PUID="fmt/3" Version="87a">
<InternalSignatureID>18</InternalSignatureID>
<Extension>gif</Extension>
Expand Down Expand Up @@ -53005,7 +53006,7 @@
<Extension>wav</Extension>
<HasPriorityOverFileFormatID>2741</HasPriorityOverFileFormatID>
</FileFormat>
<FileFormat ID="655" MIMEType="video/x-msvideo"
<FileFormat FormatType="Audio, Video" ID="655" MIMEType="video/x-msvideo"
Name="Audio/Video Interleaved Format" PUID="fmt/5">
<InternalSignatureID>51</InternalSignatureID>
<Extension>avi</Extension>
Expand Down Expand Up @@ -53060,7 +53061,7 @@
<InternalSignatureID>54</InternalSignatureID>
<Extension>wrl</Extension>
</FileFormat>
<FileFormat ID="664" MIMEType="image/png"
<FileFormat FormatType="Image (Raster)" ID="664" MIMEType="image/png"
Name="Portable Network Graphics" PUID="fmt/11" Version="1.0">
<InternalSignatureID>58</InternalSignatureID>
<Extension>png</Extension>
Expand Down Expand Up @@ -53523,7 +53524,7 @@
<InternalSignatureID>127</InternalSignatureID>
<Extension>doc</Extension>
</FileFormat>
<FileFormat ID="735" MIMEType="audio/x-wav"
<FileFormat FormatType="Audio" ID="735" MIMEType="audio/x-wav"
Name="Broadcast WAVE" PUID="fmt/1" Version="0 Generic">
<InternalSignatureID>1032</InternalSignatureID>
<Extension>wav</Extension>
Expand Down Expand Up @@ -58786,7 +58787,7 @@
<InternalSignatureID>1364</InternalSignatureID>
<Extension>exr</Extension>
</FileFormat>
<FileFormat ID="1807" Name="Nearly Raw Raster Data"
<FileFormat FormatType="Image (Raster), Dataset" ID="1807" Name="Nearly Raw Raster Data"
PUID="fmt/1002" Version="1">
<InternalSignatureID>1357</InternalSignatureID>
<Extension>nrrd</Extension>
Expand Down
12 changes: 11 additions & 1 deletion cmd/sf/pronom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type pronomIdentificationTests struct {

var skeletons = make(map[string]*fstest.MapFile)

var minimalPronom = []string{"fmt/1", "fmt/3", "fmt/5", "fmt/11", "fmt/14"}
var minimalPronom = []string{"fmt/1", "fmt/3", "fmt/5", "fmt/11", "fmt/14", "fmt/1002"}

// Populate the global skeletons map from string-based byte-sequences to
// save having to store skeletons on disk and read from them.
Expand Down Expand Up @@ -59,6 +59,7 @@ func makeSkeletons() {
"")
files["fmt-3-signature-id-18.gif"] = "4749463837613b"
files["badf00d.unknown"] = "badf00d"
files["fmt-1002-signature-id-1357.nrrd"] = "4e52524430302e3031"
for key, val := range files {
data, _ := hex.DecodeString(val)
skeletons[key] = &fstest.MapFile{Data: []byte(data)}
Expand Down Expand Up @@ -125,6 +126,15 @@ var pronomIDs = []pronomIdentificationTests{
"Audio, Video",
"extension match avi; byte match at 0, 12",
"",
}, {
"pronom",
"fmt/1002",
"Nearly Raw Raster Data",
"1",
"",
"Image (Raster), Dataset",
"extension match nrrd; byte match at 0, 9",
"",
},
}

Expand Down
1 change: 1 addition & 0 deletions pkg/config/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func Clear() func() private {
identifier.multi = Conclusive
loc.fdd = ""
mimeinfo.mi = ""
pronom.reports = "pronom"
return private{}
}
}
Expand Down
18 changes: 2 additions & 16 deletions pkg/pronom/internal/mappings/droid.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,30 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package mappings contains struct mappings to unmarshall three
// Package mappings contains struct mappings to unmarshal three
// different PRONOM XML formats: the DROID signature file format, the report
// format, and the container format.
package mappings

import "encoding/xml"

// Droid Signature File

// Droid describes the basic top-level structure of a DROID signature
// file.
type Droid struct {
XMLName xml.Name `xml:"FFSignatureFile"`
Version int `xml:",attr"`
Signatures []InternalSignature `xml:"InternalSignatureCollection>InternalSignature"`
FileFormats []FileFormat `xml:"FileFormatCollection>FileFormat"`
}

// InternalSignature describes the structure of the InternalSignature
// section of a DROID signature file.
type InternalSignature struct {
ID int `xml:"ID,attr"`
ByteSequences []ByteSeq `xml:"ByteSequence"`
}

// ByteSeq describes the structure of the ByteSequence sections of a
// DROID signature file.
type ByteSeq struct {
Reference string `xml:"Reference,attr"`
SubSequences []SubSequence `xml:"SubSequence"`
}

// SubSequence describes the structure of the SubSequence sections of a
// DROID signature file.
type SubSequence struct {
Position int `xml:",attr"`
SubSeqMinOffset string `xml:",attr"` // and empty int values are unmarshalled to 0
Expand All @@ -55,25 +45,21 @@ type SubSequence struct {
RightFragments []Fragment `xml:"RightFragment"`
}

// Fragment describes the structure of the fragment sections of a DROID
// signature file.
type Fragment struct {
Value string `xml:",chardata"`
MinOffset string `xml:",attr"`
MaxOffset string `xml:",attr"`
Position int `xml:",attr"`
}

// FileFormat describes the structure of the FileFormat section of a
// DROID signature file.
type FileFormat struct {
XMLName xml.Name `xml:"FileFormat"`
ID int `xml:"ID,attr"`
Puid string `xml:"PUID,attr"`
Name string `xml:",attr"`
Version string `xml:",attr"`
MIMEType string `xml:",attr"`
Types string `xml:"FormatTypes"`
FormatType string `xml:",attr"`
Extensions []string `xml:"Extension"`
Signatures []int `xml:"InternalSignatureID"`
Priorities []int `xml:"HasPriorityOverFileFormatID"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/pronom/parseable.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (d *droid) Infos() map[string]identifier.FormatInfo {
name: strings.TrimSpace(v.Name),
version: strings.TrimSpace(v.Version),
mimeType: strings.TrimSpace(v.MIMEType),
class: strings.TrimSpace(v.Types),
class: strings.TrimSpace(v.FormatType),
}
}
return infos
Expand Down

0 comments on commit a8c5b49

Please sign in to comment.