示例#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
}
示例#2
0
func inspectSig(f string) error {
	_, err := pronom.New(config.SetLimit(expandSets(f)), config.SetInspect(), config.SetNoContainer())
	if err != nil {
		return err
	}
	return nil
}
示例#3
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)
	}
}
示例#4
0
func makegob(s *siegfried.Siegfried, opts []config.Option) error {
	p, err := pronom.New(opts...)
	if err != nil {
		return err
	}
	err = s.Add(p)
	if err != nil {
		return err
	}
	return s.Save(config.Signature())
}
示例#5
0
func TestLoad(t *testing.T) {
	s := New()
	config.SetHome("./cmd/roy/data")
	p, err := pronom.New()
	if err != nil {
		t.Fatal(err)
	}
	err = s.Add(p)
	if err != nil {
		t.Fatal(err)
	}
}
示例#6
0
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)
}
示例#7
0
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)
	}
}
示例#8
0
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)
	}
}
示例#9
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())
}
示例#10
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
}