Exemplo n.º 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
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
// Add adds an identifier to a Siegfried struct.
// The identifer is type switched to test if it is supported. At present, only PRONOM identifiers are supported
func (s *Siegfried) Add(i core.Identifier) error {
	switch i := i.(type) {
	default:
		return fmt.Errorf("siegfried: unknown identifier type %T", i)
	case *pronom.Identifier:
		if err := i.Add(s.em, core.ExtensionMatcher); err != nil {
			return err
		}
		if err := i.Add(s.mm, core.MIMEMatcher); err != nil {
			return err
		}
		if err := i.Add(s.cm, core.ContainerMatcher); err != nil {
			return err
		}
		if err := i.Add(s.bm, core.ByteMatcher); err != nil {
			return err
		}
		if err := i.Add(s.tm, core.TextMatcher); err != nil {
			return err
		}
		s.ids = append(s.ids, i)
	}
	return nil
}
Exemplo n.º 4
0
// Add adds an identifier to a Siegfried struct.
// The identifer is type switched to test if it is supported. At present, only PRONOM identifiers are supported
func (s *Siegfried) Add(i core.Identifier) error {
	switch i := i.(type) {
	default:
		return fmt.Errorf("siegfried: unknown identifier type %T", i)
	case *pronom.Identifier:
		if err := i.Add(s.em); err != nil {
			return err
		}
		if err := i.Add(s.cm); err != nil {
			return err
		}
		if err := i.Add(s.bm); err != nil {
			return err
		}
		if err := i.Add(s.tm); err != nil {
			return err
		}
		s.ids = append(s.ids, i)
	}
	return nil
}
Exemplo n.º 5
0
// Add adds an identifier to a Siegfried struct.
func (s *Siegfried) Add(i core.Identifier) error {
	for _, v := range s.ids {
		if v.Name() == i.Name() {
			return fmt.Errorf("siegfried: identifiers must have unique names, you already have an identifier named %s. Use the -name flag to assign a new name e.g. `roy add -name richard`", i.Name())
		}
	}
	var err error
	if s.nm, err = i.Add(s.nm, core.NameMatcher); err != nil {
		return err
	}
	if s.mm, err = i.Add(s.mm, core.MIMEMatcher); err != nil {
		return err
	}
	if s.cm, err = i.Add(s.cm, core.ContainerMatcher); err != nil {
		return err
	}
	if s.xm, err = i.Add(s.xm, core.XMLMatcher); err != nil {
		return err
	}
	if s.rm, err = i.Add(s.rm, core.RIFFMatcher); err != nil {
		return err
	}
	if s.bm, err = i.Add(s.bm, core.ByteMatcher); err != nil {
		return err
	}
	if s.tm, err = i.Add(s.tm, core.TextMatcher); err != nil {
		return err
	}
	s.ids = append(s.ids, i)
	return nil
}