func savereps() error { file, err := os.Open(config.Reports()) if err != nil { err = os.Mkdir(config.Reports(), os.ModePerm) if err != nil { return fmt.Errorf("roy: error making reports directory") } } file.Close() errs := pronom.Harvest() if len(errs) > 0 { return fmt.Errorf("roy: errors saving reports to disk") } return nil }
// UTILS // Harvest fetches PRONOM reports listed in the DROID file func Harvest() []error { d, err := newDroid(config.Droid()) if err != nil { return []error{err} } apply := func(puid string) error { url, _, _, _ := config.HarvestOptions() return save(puid, url, config.Reports()) } return applyAll(5, d.IDs(), apply) }
// 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 }
func reportPath(puid string) string { return filepath.Join(config.Reports(), strings.Replace(puid, "/", "", 1)+".xml") }