Example #1
0
func inspectFmt(f string) error {
	var id core.Identifier
	var err error
	fs := expandSets(f)
	if len(fs) == 0 {
		return fmt.Errorf("no valid fmt to inspect in %s", f)
	}
	opts := append(getOptions(), config.SetDoubleUp()) // speed up by allowing sig double ups
	if *inspectMI != "" {
		id, err = mimeinfo.New(opts...)
	} else if strings.HasPrefix(fs[0], "fdd") || *inspectLOC || (*inspectFDD != "") {
		if *inspectFDD == "" && !*inspectLOC {
			opts = append(opts, config.SetLOC(""))
		}
		id, err = loc.New(opts...)
	} else {
		if !*inspectReports {
			opts = append(opts, config.SetNoReports()) // speed up by building from droid xml
		}
		id, err = pronom.New(opts...)
	}
	if err != nil {
		return err
	}
	fmt.Println(id.Inspect(fs...))
	return nil
}
Example #2
0
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)
	}
}
Example #3
0
func makegob(s *siegfried.Siegfried, opts []config.Option) error {
	var id core.Identifier
	var err error
	if *mi != "" {
		id, err = mimeinfo.New(opts...)
	} else if *locfdd || *fdd != "" {
		id, err = loc.New(opts...)
	} else {
		id, err = pronom.New(opts...)
	}
	if err != nil {
		return err
	}
	err = s.Add(id)
	if err != nil {
		return err
	}
	return s.Save(config.Signature())
}
Example #4
0
func graphPriorities(typ int) error {
	var id core.Identifier
	var err error
	opts := append(getOptions(), config.SetDoubleUp()) // speed up by allowing sig double ups
	if *inspectMI != "" {
		id, err = mimeinfo.New(opts...)
	} else if *inspectLOC || (*inspectFDD != "") {
		id, err = loc.New(opts...)
	} else {
		if !*inspectReports {
			opts = append(opts, config.SetNoReports()) // speed up by building from droid xml
		}
		id, err = pronom.New(opts...)
	}
	if err != nil {
		return err
	}
	fmt.Println(id.GraphP(typ))
	return nil
}