3 Pattern = re._pattern_type
11 comment = re.compile(
r"#.*")
14 if isinstance(branchsel, list):
17 elif isinstance(branchsel, str):
20 for line
in open(branchsel,
'r'): 22 if len(line) == 0
or line[0] ==
'#':
24 line = re.sub(comment,
"", line)
25 while line[-1] ==
"\\":
26 line = line[:-1] +
" " + file.next().
strip()
27 line = re.sub(comment,
"", line)
32 (op, sel) = line.split()
37 elif op ==
"keepmatch":
38 ops.append((re.compile(
"(:?%s)$" % sel), 1))
39 elif op ==
"dropmatch":
40 ops.append((re.compile(
"(:?%s)$" % sel), 0))
42 print(
"Error in branchsel: line '%s': "% (line)
43 +
"it's not (keep|keepmatch|drop|dropmatch) " 46 except ValueError
as e:
47 print(
"Error in branchsel: line '%s': " % (line)
48 +
"it's not (keep|keepmatch|drop|dropmatch) " 54 tree.SetBranchStatus(
"*", 1)
55 branchNames = [b.GetName()
for b
in tree.GetListOfBranches()]
56 for bre, stat
in self.
_ops:
57 if type(bre) == Pattern:
60 tree.SetBranchStatus(n, stat)
62 tree.SetBranchStatus(bre, stat)
def selectBranches(self, tree)
def __init__(self, branchsel)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)