示例#1
0
// Pronom creates a pronom object
func NewPronom() (identifier.Parseable, error) {
	p := &pronom{
		c: identifier.Blank{},
	}
	// apply no container rule
	if !config.NoContainer() {
		if err := p.setContainers(); err != nil {
			return nil, fmt.Errorf("Pronom: error loading containers; got %s\nUnless you have set `-nocontainer` you need to download a container signature file", err)
		}
	}
	if err := p.setParseables(); err != nil {
		return nil, err
	}
	return identifier.ApplyConfig(p), nil
}
示例#2
0
func ApplyConfig(p Parseable) Parseable {
	if config.NoName() {
		p = noName{p}
	}
	if config.NoMIME() {
		p = noMIME{p}
	}
	if config.NoXML() {
		p = noXML{p}
	}
	if config.NoContainer() {
		p = noContainers{p}
	}
	if config.NoRIFF() {
		p = noRIFF{p}
	}
	if config.NoText() {
		p = noText{p}
	}
	if config.NoPriority() {
		p = noPriority{p}
	}
	// mirror PREV wild segments into EOF if maxBof and maxEOF set
	if config.MaxBOF() > 0 && config.MaxEOF() > 0 {
		p = Mirror{p}
	}
	if config.HasLimit() || config.HasExclude() {
		ids := p.IDs()
		if config.HasLimit() {
			ids = config.Limit(ids)
		} else {
			ids = config.Exclude(ids)
		}
		p = Filter(ids, p)
	}
	return p
}