@@ -339,26 +339,42 @@ def _parse_nh_struct(text):
339339
340340
341341def _compose_spans (span_matches , spans_name ):
342+ """Takes a list of span matches (expected to be a list of tuples) and a string
343+ (the expected span list name) and processes the list so that the values extracted
344+ from the span matches can be used to compose a tuple of BucketSpan objects"""
342345 spans = {}
343346 for match in span_matches :
347+ # Extract the key from the match (first element of the tuple).
344348 key = match [0 ]
349+ # Extract the value from the match (second element of the tuple).
350+ # Split the value string by commas to get individual pairs,
351+ # split each pair by ':' to get start and end, and convert them to integers.
345352 value = [tuple (map (int , pair .split (':' ))) for pair in match [1 ].split (',' )]
353+ # Store the processed value in the spans dictionary with the key.
346354 spans [key ] = value
347355 if spans_name not in spans :
348356 return None
349357 out_spans = []
358+ # Iterate over each start and end tuple in the list of tuples for the specified spans_name.
350359 for start , end in spans [spans_name ]:
360+ # Compose a BucketSpan object with the start and end values
361+ # and append it to the out_spans list.
351362 out_spans .append (BucketSpan (start , end ))
363+ # Convert to tuple
352364 out_spans_tuple = tuple (out_spans )
353365 return out_spans_tuple
354366
355367
356368def _compose_deltas (deltas , deltas_name ):
369+ """Takes a list of deltas matches (a dictionary) and a string (the expected delta list name),
370+ and processes its elements to compose a tuple of integers representing the deltas"""
357371 if deltas_name not in deltas :
358372 return None
359373 out_deltas = deltas .get (deltas_name )
360374 if out_deltas is not None and out_deltas .strip ():
361375 elems = out_deltas .split (',' )
376+ # Convert each element in the list elems to an integer
377+ # after stripping whitespace and create a tuple from these integers.
362378 out_deltas_tuple = tuple (int (x .strip ()) for x in elems )
363379 return out_deltas_tuple
364380
0 commit comments