|
[yoda-svn] yoda: Add missing yoda2yodaYODA Mercurial yoda at projects.hepforge.orgFri Jul 22 15:45:01 BST 2016
details: https://yoda.hepforge.org/hg/yoda/rev/4ee0ee3eea94 branches: release-1-6 changeset: 1283:4ee0ee3eea94 user: Andy Buckley <andy at insectnation.org> date: Fri Jul 22 15:41:28 2016 +0100 description: Add missing yoda2yoda diffs (31 lines): --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/yoda2yoda Fri Jul 22 15:41:28 2016 +0100 @@ -0,0 +1,28 @@ +#! /usr/bin/env python + +"""\ +%prog yodafile [yodafile2] + +Convert a YODA data file to another YODA file (for convenient tidying and filtering). +Like yodacnv, but allows output to stdout since the output format isn't auto-detected. +""" + +import yoda, os, sys, optparse +from yoda.script_helpers import parse_x2y_args, filter_aos + +parser = optparse.OptionParser(usage=__doc__) +parser.add_option("-m", "--match", dest="MATCH", metavar="PATT", default=None, + help="Only write out histograms whose path matches this regex") +parser.add_option("-M", "--unmatch", dest="UNMATCH", metavar="PATT", default=None, + help="Exclude histograms whose path matches this regex") + +opts, args = parser.parse_args() +in_out = parse_x2y_args(args, ".yoda", ".yoda") +if not in_out: + sys.stderr.write("You must specify the YODA input and output file names\n") + sys.exit(1) + +for i, o in in_out: + analysisobjects = yoda.readYODA(i) + filter_aos(analysisobjects, opts.MATCH, opts.UNMATCH) + yoda.writeYODA(analysisobjects, o)
More information about the yoda-svn mailing list |