Beispiel #1
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
}
Beispiel #2
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
}
Beispiel #3
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
}