Example #1
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
}
Example #2
0
// set identifiers joins signatures in the DROID signature file with any extra reports and adds that to the pronom object
func (p *pronom) setParseables() error {
	d, err := newDroid(config.Droid())
	if err != nil {
		return fmt.Errorf("Pronom: error loading Droid file; got %s\nYou must have a Droid file to build a signature", err)
	}

	// if noreports set
	if config.Reports() == "" {
		p.Parseable = d
	} else { // otherwise build from reports
		// get list of puids that applies limit or exclude filters (actual filtering of Parseable delegated to core/identifier)
		puids := d.IDs()
		if config.HasLimit() {
			puids = config.Limit(puids)
		} else if config.HasExclude() {
			puids = config.Exclude(puids)
		}
		r, err := newReports(puids, d.idsPuids())
		if err != nil {
			return fmt.Errorf("Pronom: error loading reports; got %s\nYou must download PRONOM reports to build a signature (unless you use the -noreports flag). You can use `roy harvest` to download reports", err)
		}
		p.Parseable = r
	}
	// add extensions
	for _, v := range config.Extend() {
		e, err := newDroid(v)
		if err != nil {
			return fmt.Errorf("Pronom: error loading extension file; got %s", err)
		}
		p.Parseable = identifier.Join(p.Parseable, e)
	}
	// exclude byte signatures where also have container signatures, unless doubleup set
	if !config.DoubleUp() {
		p.Parseable = doublesFilter{
			config.ExcludeDoubles(p.IDs(), p.c.IDs()),
			p.Parseable,
		}
	}
	return nil
}