func TestMakePronomTika(t *testing.T) { s := siegfried.New() config.SetHome(*testhome) p, err := pronom.New() if err != nil { t.Fatal(err) } err = s.Add(p) if err != nil { t.Fatal(err) } m, err := mimeinfo.New(config.SetName("tika"), config.SetMIMEInfo("tika")) if err != nil { t.Fatal(err) } err = s.Add(m) if err != nil { t.Fatal(err) } l, err := loc.New(config.SetName("loc"), config.SetLOC("")) if err != nil { t.Fatal(err) } err = s.Add(l) if err != nil { t.Fatal(err) } sigs := filepath.Join("data", "pronom-tika-loc.sig") err = s.Save(sigs) if err != nil { t.Fatal(err) } }
func setup(opts ...config.Option) error { if opts == nil && s != nil { return nil } var err error s = siegfried.New() config.SetHome(*testhome) opts = append(opts, config.SetDoubleUp()) p, err := pronom.New(opts...) if err != nil { return err } return s.Add(p) }
func TestMakeGob(t *testing.T) { s := siegfried.New() config.SetHome(*testhome) p, err := pronom.New() if err != nil { t.Fatal(err) } err = s.Add(p) if err != nil { t.Fatal(err) } sigs := filepath.Join("data", config.SignatureBase()) err = s.Save(sigs) if err != nil { t.Fatal(err) } }
func TestMakeArchivematica(t *testing.T) { s := siegfried.New() config.SetHome(*testhome) p, err := pronom.New( config.SetName("archivematica"), config.SetExtend(expandSets("archivematica-fmt2.xml,archivematica-fmt3.xml,archivematica-fmt4.xml,archivematica-fmt5.xml"))) if err != nil { t.Fatal(err) } err = s.Add(p) if err != nil { t.Fatal(err) } sigs := filepath.Join("data", "archivematica.sig") err = s.Save(sigs) if err != nil { t.Fatal(err) } }
func main() { var err error if len(os.Args) < 2 { log.Fatal(usage) } switch os.Args[1] { case "build": err = build.Parse(os.Args[2:]) if err == nil { if build.Arg(0) != "" { config.SetSignature(build.Arg(0)) } s := siegfried.New() err = makegob(s, buildOptions()) } case "add": err = build.Parse(os.Args[2:]) if err == nil { if build.Arg(0) != "" { config.SetSignature(build.Arg(0)) } var s *siegfried.Siegfried s, err = siegfried.Load(config.Signature()) if err == nil { err = makegob(s, buildOptions()) } } case "harvest": err = harvest.Parse(os.Args[2:]) if err == nil { setHarvestOptions() err = savereps() } case "inspect": err = inspect.Parse(os.Args[2:]) if err == nil { setInspectOptions() input := inspect.Arg(0) switch { case input == "": err = inspectGob() case filepath.Ext(input) == ".sig": config.SetSignature(input) err = inspectGob() case strings.Contains(input, "fmt"): err = inspectSig(input) default: var i int i, err = strconv.Atoi(input) if err != nil { log.Fatal(err) } err = blameSig(i) } } default: log.Fatal(usage) } if err != nil { log.Fatal(err) } os.Exit(0) }
func main() { var err error if len(os.Args) < 2 { log.Fatal(usage) } switch os.Args[1] { case "build": err = build.Parse(os.Args[2:]) if err == nil { if build.Arg(0) != "" { config.SetSignature(build.Arg(0)) } s := siegfried.New() err = makegob(s, getOptions()) } case "add": err = build.Parse(os.Args[2:]) if err == nil { if build.Arg(0) != "" { config.SetSignature(build.Arg(0)) } var s *siegfried.Siegfried s, err = siegfried.Load(config.Signature()) if err == nil { err = makegob(s, getOptions()) } } case "harvest": err = harvest.Parse(os.Args[2:]) if err == nil { setHarvestOptions() err = savereps() } case "inspect": inspect.Usage = func() { fmt.Print(inspectUsage) } err = inspect.Parse(os.Args[2:]) if err == nil { input := inspect.Arg(0) switch { case input == "": err = inspectSig(-1) case input == "bytematcher", input == "bm": err = inspectSig(core.ByteMatcher) case input == "containermatcher", input == "cm": err = inspectSig(core.ContainerMatcher) case input == "namematcher", input == "nm": err = inspectSig(core.NameMatcher) case input == "mimematcher", input == "mm": err = inspectSig(core.MIMEMatcher) case input == "riffmatcher", input == "rm": err = inspectSig(core.RIFFMatcher) case input == "xmlmatcher", input == "xm": err = inspectSig(core.XMLMatcher) case input == "textmatcher", input == "tm": err = inspectSig(core.TextMatcher) case input == "priorities", input == "p": err = graphPriorities(0) case input == "missing-priorities", input == "mp": err = graphPriorities(1) case input == "implicit-priorities", input == "ip": err = graphPriorities(2) case filepath.Ext(input) == ".sig": config.SetSignature(input) err = inspectSig(-1) case strings.Contains(input, "fmt"), *inspectMI != "", strings.HasPrefix(input, "fdd"), strings.HasPrefix(input, "@"): err = inspectFmt(input) default: var i int i, err = strconv.Atoi(input) if err == nil { err = blameSig(i) } else { err = inspectFmt(input) } } } default: log.Fatal(usage) } if err != nil { log.Fatal(err) } os.Exit(0) }