File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,12 @@ def analyze_extensions(
145
145
# Convert to list for output
146
146
return list (extension_stats .values ())
147
147
148
+ def snapshot_result (result , output ):
149
+ out = json .dumps (result , indent = 2 , cls = EnhancedJSONEncoder )
150
+ if output :
151
+ with open (output , "w" ) as f :
152
+ f .write (out )
153
+ return out
148
154
149
155
def main ():
150
156
parser = argparse .ArgumentParser (description = "Analyze NWB file extensions" )
@@ -180,6 +186,7 @@ def main():
180
186
urls = get_s3_urls_and_dandi_paths (dandiset_id = d )
181
187
nwb_urls = [url for url , path in urls .items () if path .endswith (".nwb" )]
182
188
result [d ] = analyze_extensions (nwb_urls , True )
189
+ snapshot_result (result , args .output )
183
190
else :
184
191
if args .files :
185
192
file_paths = args .files
@@ -197,12 +204,8 @@ def main():
197
204
result = [asdict (stat ) for stat in extension_stats ]
198
205
199
206
# Output results
200
- out = json .dumps (result , indent = 2 , cls = EnhancedJSONEncoder )
201
- if args .output :
202
- with open (args .output , "w" ) as f :
203
- f .write (out )
204
- print (f"Results written to { args .output } " )
205
- else :
207
+ out = snapshot_result (result , args .output )
208
+ if not args .output :
206
209
print (out )
207
210
208
211
You can’t perform that action at this time.
0 commit comments