Skip to content

Commit e71a01e

Browse files
committed
Comments on helpers
1 parent 139708e commit e71a01e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

servicex_analysis_utils/file_peeking.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,23 @@ def print_structure_from_str(deliver_dict, filter_branch="", save_to_txt=False,
111111
with uproot.open(path[0]) as f:
112112
structure_str = f["servicex"]["branch"].array()[0]
113113

114+
# Trees separated by \n
114115
tree_lines = structure_str.split("\n")
115116
for line in tree_lines:
116117
if not line.strip():
117118
continue # Skip empty lines
118119

120+
#Separate Tree header from branches
119121
parts = line.split(";", 1)
120122
tree_header = parts[0]
121123
output_lines.append(f"\n\U0001F333 {tree_header}")
122124

123125
if len(parts) > 1:
124-
branch_infos = parts[1].split(",")
126+
branch_infos = parts[1].split(",") # Branches separated by ,
125127
output_lines.append(" ├── Branches:")
126128
for b in branch_infos:
127-
branch_line = b.strip()
129+
branch_line = b.strip()
130+
# Removes lines w/o filter str
128131
if filter_branch not in branch_line:
129132
continue
130133
if branch_line.startswith("TBranch:"):
@@ -175,7 +178,7 @@ def build_deliver_spec(dataset):
175178
return spec_python
176179

177180

178-
def get_structure(dataset, **kwargs):
181+
def get_structure(dataset, **kwargs, raw=False):
179182
"""
180183
Utility function.
181184
Creates and sends the ServiceX request from user inputed datasets to retrieve file stucture.
@@ -190,4 +193,7 @@ def get_structure(dataset, **kwargs):
190193

191194
output=servicex.deliver(spec_python)
192195

196+
if raw:
197+
return array_from_str(output)
198+
193199
return print_structure_from_str(output, **kwargs)

0 commit comments

Comments
 (0)