@@ -498,8 +498,9 @@ def _build_common_metadata(
498498 tuple[dict, dict]
499499 (global_info, capture_info) dictionaries.
500500 """
501- # helper to look up extended header values by tag
501+
502502 def get_tag (tag ):
503+ """helper to look up extended header values by tag"""
503504 for entry in h_extended :
504505 if entry ["tag" ] == tag :
505506 return entry ["value" ]
@@ -670,6 +671,7 @@ def construct_sigmf(
670671 h_extended : list ,
671672 is_metadata_only : bool = False ,
672673 create_archive : bool = False ,
674+ overwrite : bool = False ,
673675) -> SigMFFile :
674676 """
675677 Built & write a SigMF object from BLUE metadata.
@@ -688,6 +690,8 @@ def construct_sigmf(
688690 If True, creates a metadata-only SigMF file.
689691 create_archive : bool, optional
690692 When True, package output as SigMF archive instead of a meta/data pair.
693+ overwrite : bool, optional
694+ If False, raise exception if output files already exist.
691695
692696 Returns
693697 -------
@@ -723,12 +727,12 @@ def construct_sigmf(
723727 meta .add_capture (0 , metadata = capture_info )
724728
725729 if create_archive :
726- meta .tofile (filenames ["archive_fn" ], toarchive = True )
730+ meta .tofile (filenames ["archive_fn" ], toarchive = True , overwrite = overwrite )
727731 log .info ("wrote SigMF archive to %s" , filenames ["archive_fn" ])
728732 # metadata returned should be for this archive
729733 meta = fromfile (filenames ["archive_fn" ])
730734 else :
731- meta .tofile (filenames ["meta_fn" ], toarchive = False )
735+ meta .tofile (filenames ["meta_fn" ], toarchive = False , overwrite = overwrite )
732736 log .info ("wrote SigMF metadata to %s" , filenames ["meta_fn" ])
733737
734738 log .debug ("created %r" , meta )
@@ -790,6 +794,7 @@ def blue_to_sigmf(
790794 out_path : Optional [str ] = None ,
791795 create_archive : bool = False ,
792796 create_ncd : bool = False ,
797+ overwrite : bool = False ,
793798) -> SigMFFile :
794799 """
795800 Read a MIDAS Bluefile, optionally write SigMF, return associated SigMF object.
@@ -804,6 +809,8 @@ def blue_to_sigmf(
804809 When True, package output as a .sigmf archive.
805810 create_ncd : bool, optional
806811 When True, create Non-Conforming Dataset with header_bytes and trailing_bytes.
812+ overwrite : bool, optional
813+ If False, raise exception if output files already exist.
807814
808815 Returns
809816 -------
@@ -846,7 +853,7 @@ def blue_to_sigmf(
846853
847854 # write NCD metadata to specified output path if provided
848855 if out_path is not None :
849- ncd_meta .tofile (filenames ["meta_fn" ])
856+ ncd_meta .tofile (filenames ["meta_fn" ], overwrite = overwrite )
850857 log .info ("wrote SigMF non-conforming metadata to %s" , filenames ["meta_fn" ])
851858
852859 return ncd_meta
@@ -872,6 +879,7 @@ def blue_to_sigmf(
872879 h_extended = h_extended ,
873880 is_metadata_only = metadata_only ,
874881 create_archive = create_archive ,
882+ overwrite = overwrite ,
875883 )
876884
877885 log .debug (">>>>>>>>> Fixed Header" )
0 commit comments