|
[Rivet-svn] rivet: Allow use of path regex group references in .plot file ke...Rivet Mercurial rivet at projects.hepforge.orgWed Jul 20 11:45:02 BST 2016
details: https://rivet.hepforge.org/hg/rivet/rev/1d7156b1f100 branches: release-2-5-x changeset: 5322:1d7156b1f100 user: Andy Buckley <andy at insectnation.org> date: Wed Jul 20 11:33:02 2016 +0100 description: Allow use of path regex group references in .plot file keyed values. diffs (truncated from 56 to 50 lines): --- a/ChangeLog Wed Jul 20 09:14:30 2016 +0100 +++ b/ChangeLog Wed Jul 20 11:33:02 2016 +0100 @@ -1,3 +1,11 @@ +2016-07-20 Andy Buckley <andy.buckley at cern.ch> + + * Allow use of path regex group references in .plot file keyed values. + +2016-07-20 Holger Schulz <holger.schulz at cern.ch> + + * Fix the --nskip behaviour on the main rivet script. + 2016-07-07 Andy Buckley <andy.buckley at cern.ch> * Release version 2.5.0 --- a/pyext/rivet/plotinfo.py Wed Jul 20 09:14:30 2016 +0100 +++ b/pyext/rivet/plotinfo.py Wed Jul 20 11:33:02 2016 +0100 @@ -90,16 +90,18 @@ return startreading = False f = open(plotfile) + msec = None for line in f: m = self.pat_begin_block.match(line) if m: tag, pathpat = m.group(2,3) - #print tag, pathpat # pathpat could be a regex if not self.pat_paths.has_key(pathpat): self.pat_paths[pathpat] = re.compile(pathpat) if tag == section: - if self.pat_paths[pathpat].match(hpath): + m2 = self.pat_paths[pathpat].match(hpath) + if m2: + msec = m2 startreading = True if section in ['SPECIAL']: ret[section] = '' @@ -115,8 +117,16 @@ vm = self.pat_property.match(line) if vm: prop, value = vm.group(1,2) - #print prop, value - ret[section][prop] = texpand(value) + if msec: + try: + ## First escape backslashes *except* regex groups, then expand regex groups from path match + value = value.encode("string-escape") + value = re.sub("(\\\\)(\\d|g)", "\\2", value) #< r-strings actually made this harder, since the \) is still treated as an escape! + value = msec.expand(value) + except Exception as e:
More information about the Rivet-svn mailing list |