From a8c5b493820fb1847845743fa0fb53aa688c1be0 Mon Sep 17 00:00:00 2001 From: ross-spencer Date: Sun, 5 Nov 2023 18:17:40 +0100 Subject: [PATCH] CR changes and updated DROID XML --- cmd/roy/data/DROID_SignatureFile_V114.xml | 13 +++++++------ cmd/sf/pronom_test.go | 12 +++++++++++- pkg/config/identifier.go | 1 + pkg/pronom/internal/mappings/droid.go | 18 ++---------------- pkg/pronom/parseable.go | 2 +- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/cmd/roy/data/DROID_SignatureFile_V114.xml b/cmd/roy/data/DROID_SignatureFile_V114.xml index 24961455..844e7f40 100644 --- a/cmd/roy/data/DROID_SignatureFile_V114.xml +++ b/cmd/roy/data/DROID_SignatureFile_V114.xml @@ -1,4 +1,5 @@ + @@ -52744,7 +52745,7 @@ PUID="fmt/9" Version="5"/> - 123 @@ -52792,7 +52793,7 @@ 687 869 - 18 gif @@ -53005,7 +53006,7 @@ wav 2741 - 51 avi @@ -53060,7 +53061,7 @@ 54 wrl - 58 png @@ -53523,7 +53524,7 @@ 127 doc - 1032 wav @@ -58786,7 +58787,7 @@ 1364 exr - 1357 nrrd diff --git a/cmd/sf/pronom_test.go b/cmd/sf/pronom_test.go index 4980b5ff..422e7de9 100644 --- a/cmd/sf/pronom_test.go +++ b/cmd/sf/pronom_test.go @@ -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. @@ -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)} @@ -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", + "", }, } diff --git a/pkg/config/identifier.go b/pkg/config/identifier.go index db31f365..09e072b2 100644 --- a/pkg/config/identifier.go +++ b/pkg/config/identifier.go @@ -324,6 +324,7 @@ func Clear() func() private { identifier.multi = Conclusive loc.fdd = "" mimeinfo.mi = "" + pronom.reports = "pronom" return private{} } } diff --git a/pkg/pronom/internal/mappings/droid.go b/pkg/pronom/internal/mappings/droid.go index b9f63cc9..e8dc8f05 100644 --- a/pkg/pronom/internal/mappings/droid.go +++ b/pkg/pronom/internal/mappings/droid.go @@ -12,17 +12,13 @@ // 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"` @@ -30,22 +26,16 @@ type Droid struct { 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 @@ -55,8 +45,6 @@ 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"` @@ -64,8 +52,6 @@ type Fragment struct { 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"` @@ -73,7 +59,7 @@ type FileFormat struct { 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"` diff --git a/pkg/pronom/parseable.go b/pkg/pronom/parseable.go index 8f39c1e0..59d617f2 100644 --- a/pkg/pronom/parseable.go +++ b/pkg/pronom/parseable.go @@ -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