@@ -99,7 +99,7 @@ def get_files(self, capture: Capture) -> ReturnList[File]:
9999 @extend_schema_field (serializers .IntegerField (allow_null = True ))
100100 def get_total_file_size (self , capture : Capture ) -> int | None :
101101 """Get the total file size of all files associated with this capture."""
102-
102+
103103 if capture .capture_type != CaptureType .DigitalRF :
104104 return None
105105
@@ -109,11 +109,16 @@ def get_total_file_size(self, capture: Capture) -> int | None:
109109 data_total = self .get_data_files_info (capture ).get ("total_size" , 0 )
110110 if total < data_total :
111111 logging .getLogger (__name__ ).warning (
112- "Capture %s: total_file_size (%s) < data_files_total_size (%s); using data total." ,
113- str (capture .uuid ), total , data_total ,
112+ (
113+ "Capture %s: total_file_size (%s) < data_files_total_size (%s); "
114+ "using data total."
115+ ),
116+ str (capture .uuid ),
117+ total ,
118+ data_total ,
114119 )
115120 total = data_total
116-
121+
117122 return total
118123
119124 @extend_schema_field (serializers .DictField (allow_null = True ))
@@ -135,17 +140,19 @@ def get_data_files_info(self, capture: Capture) -> dict[str, Any]:
135140 def get_center_frequency_ghz (self , capture : Capture ) -> float | None :
136141 """Get the center frequency in GHz from the capture model property."""
137142 return capture .center_frequency_ghz
138-
143+
139144 @extend_schema_field (serializers .FloatField (allow_null = True ))
140145 def get_sample_rate_mhz (self , capture : Capture ) -> float | None :
141- """Get the sample rate in MHz from the capture model property . None if not indexed in OpenSearch."""
146+ """Sample rate in MHz from the model. None if not indexed in OpenSearch."""
142147 return capture .sample_rate_mhz
143148
144149 @extend_schema_field (serializers .IntegerField (allow_null = True ))
145150 def get_length_of_capture_ms (self , capture : Capture ) -> int | None :
146- """Get the length of the capture in milliseconds. OpenSearch bounds are in seconds."""
151+ """Capture length in milliseconds ( OpenSearch bounds are seconds) ."""
147152 try :
148- start_time , end_time = get_capture_bounds (capture .capture_type , str (capture .uuid ))
153+ start_time , end_time = get_capture_bounds (
154+ capture .capture_type , str (capture .uuid )
155+ )
149156 return (end_time - start_time ) * 1000
150157 except (ValueError , IndexError , KeyError ):
151158 return None
@@ -160,13 +167,14 @@ def get_file_cadence_ms(self, capture: Capture) -> int | None:
160167
161168 @extend_schema_field (serializers .IntegerField (allow_null = True ))
162169 def get_capture_start_epoch_sec (self , capture : Capture ) -> int | None :
163- """Get the capture start time as Unix epoch seconds. None if not indexed in OpenSearch."""
170+ """Capture start as Unix epoch seconds. None if not in OpenSearch."""
164171 try :
165172 start_time , _ = get_capture_bounds (capture .capture_type , str (capture .uuid ))
166- return start_time
167173 except (ValueError , IndexError , KeyError ):
168174 return None
169-
175+ else :
176+ return start_time
177+
170178 @extend_schema_field (serializers .DictField )
171179 def get_capture_props (self , capture : Capture ) -> dict [str , Any ]:
172180 """Retrieve the indexed metadata for the capture."""
@@ -382,21 +390,25 @@ def get_total_file_size(self, obj: dict[str, Any]) -> int | None:
382390 """Get the total file size across all channels."""
383391 if obj ["capture_type" ] != CaptureType .DigitalRF :
384392 return None
385-
393+
386394 total_size = 0
387395 for channel_data in obj ["channels" ]:
388396 capture_uuid = channel_data ["uuid" ]
389397 capture = Capture .objects .get (uuid = capture_uuid )
390398 all_files = get_capture_files (capture , include_deleted = False )
391399 result = all_files .aggregate (total_size = Sum ("size" ))
392400 total_size += result ["total_size" ] or 0
393-
401+
394402 data_total = self .get_data_files_info (obj ).get ("total_size" , 0 )
395-
403+
396404 if total_size < data_total :
397405 logging .getLogger (__name__ ).warning (
398- "Composite capture: total_file_size (%s) < data_files_total_size (%s); using data total." ,
399- total_size , data_total ,
406+ (
407+ "Composite capture: total_file_size (%s) < "
408+ "data_files_total_size (%s); using data total."
409+ ),
410+ total_size ,
411+ data_total ,
400412 )
401413 total_size = data_total
402414 return total_size
@@ -405,7 +417,7 @@ def get_data_files_info(self, obj: dict[str, Any]) -> dict[str, Any]:
405417 """Get the data files info for the composite capture."""
406418 if obj ["capture_type" ] != CaptureType .DigitalRF :
407419 return {}
408-
420+
409421 total_count = 0
410422 total_size = 0
411423 for channel_data in obj ["channels" ]:
@@ -418,7 +430,9 @@ def get_data_files_info(self, obj: dict[str, Any]) -> dict[str, Any]:
418430 return {
419431 "count" : total_count ,
420432 "total_size" : total_size ,
421- "per_data_file_size" : (float (total_size ) / total_count ) if total_count else None ,
433+ "per_data_file_size" : (float (total_size ) / total_count )
434+ if total_count
435+ else None ,
422436 }
423437
424438 @extend_schema_field (serializers .CharField )
@@ -464,12 +478,11 @@ def get_capture_start_epoch_sec(self, obj: dict[str, Any]) -> int | None:
464478 return None
465479 try :
466480 capture = Capture .objects .get (uuid = channels [0 ]["uuid" ])
467- start_time , _ = get_capture_bounds (
468- capture .capture_type , str (capture .uuid )
469- )
470- return start_time
481+ start_time , _ = get_capture_bounds (capture .capture_type , str (capture .uuid ))
471482 except (ValueError , IndexError , KeyError ):
472483 return None
484+ else :
485+ return start_time
473486
474487
475488def build_composite_capture_data (captures : list [Capture ]) -> dict [str , Any ]:
0 commit comments