Skip to content

Commit

Permalink
Add new parameter --input-file-filter
Browse files Browse the repository at this point in the history
This lets the user filter the files in the input directory by a regex
  • Loading branch information
EinarElen authored and tomeichlersmith committed Nov 3, 2023
1 parent 2372b80 commit 08daea2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Validation/src/Validation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
parser.add_argument('--param',
nargs='+',
help='parameter(s) in filename to use as file labels')
parser.add_argument('--input-file-filter', type=str,
help="""Filter which root files in the input data directory to
use using a regular expression""")
parser.add_argument('--input-files', nargs='+', type=str,
help="""Specify the name of the root files directly (either
full/relative path or name of files in the input data directory)""")
Expand Down Expand Up @@ -94,6 +97,12 @@
root_files = [ File.from_path(os.path.join(data,f), legendlabel_parameter = arg.param)
for f in os.listdir(data) if f.endswith('.root') ]

if arg.input_file_filter:
# Not sure if this can be done in one step so doing it in two
filtered_files = [f for f in root_files
if re.search(arg.input_file_filter, f.path) ]
root_files = filtered_files

logging.debug(f'ROOT Files: {root_files}')

hd = Differ(label, output_type, *[f for f in root_files if not f.is_events()])
Expand Down

0 comments on commit 08daea2

Please sign in to comment.