Skip to content

Commit 30e0955

Browse files
committed
Removing --save-to-txt arg on CLI
1 parent 95803a6 commit 30e0955

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

servicex_analysis_utils/cli.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,59 @@
22
import sys
33
import json
44
import os
5-
from .file_peeking import get_structure
5+
from .file_peeking import get_structure
66

7-
def run_from_command():
8-
parser = argparse.ArgumentParser(description="CLI tool for retrieving ROOT file structures.")
97

10-
parser.add_argument("dataset", nargs='+', help="Input datasets (Rucio DID) or a JSON file containing datasets in a dict.")
11-
parser.add_argument("--filter-branch", default="", help="Only display branches containing this string.")
12-
parser.add_argument("--save-to-txt", action="store_true", help="Save output to a text file instead of printing.")
8+
def run_from_command():
9+
parser = argparse.ArgumentParser(
10+
description="CLI tool for retrieving ROOT file structures."
11+
)
12+
13+
parser.add_argument(
14+
"dataset",
15+
nargs="+",
16+
help="Input datasets (Rucio DID) or a JSON file containing datasets in a dict.",
17+
)
18+
parser.add_argument(
19+
"--filter-branch",
20+
default="",
21+
help="Only display branches containing this string.",
22+
)
1323

1424
args = parser.parse_args()
1525

1626
if len(args.dataset) == 1 and args.dataset[0].endswith(".json"):
1727
dataset_file = args.dataset[0]
18-
28+
1929
if not os.path.isfile(dataset_file):
20-
print(f"\033[91mError: JSON file '{dataset_file}' not found.\033[0m", file=sys.stderr)
30+
print(
31+
f"\033[91mError: JSON file '{dataset_file}' not found.\033[0m",
32+
file=sys.stderr,
33+
)
2134
sys.exit(1)
2235

2336
try:
2437
with open(dataset_file, "r") as f:
25-
dataset = json.load(f)
26-
38+
dataset = json.load(f)
39+
2740
if not isinstance(dataset, dict):
28-
print(f"\033[91mError: The JSON file must contain a dictionary.\033[0m", file=sys.stderr)
41+
print(
42+
f"\033[91mError: The JSON file must contain a dictionary.\033[0m",
43+
file=sys.stderr,
44+
)
2945
sys.exit(1)
30-
46+
3147
except json.JSONDecodeError:
32-
print(f"\033[91mError: '{dataset_file}' is not a valid JSON file.\033[0m", file=sys.stderr)
48+
print(
49+
f"\033[91mError: '{dataset_file}' is not a valid JSON file.\033[0m",
50+
file=sys.stderr,
51+
)
3352
sys.exit(1)
3453

3554
else:
3655
# If dataset is provided directly in CLI, use it as a list
3756
dataset = args.dataset
3857

39-
result = get_structure(dataset, filter_branch=args.filter_branch, save_to_txt=args.save_to_txt, do_print=False)
58+
result = get_structure(dataset, filter_branch=args.filter_branch, do_print=False)
4059

41-
if not args.save_to_txt:
42-
print(result)
43-
else:
44-
print("Saved to samples_structure.txt")
60+
print(result)

0 commit comments

Comments
 (0)