Skip to content

Commit deaea7a

Browse files
committed
add conversion checks based on feedback from KelseyCreekSoftware
1 parent dcd8d7a commit deaea7a

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

docs/source/converters.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ BLUE Converter
9797

9898
The BLUE converter handles CDIF (.cdif) recordings while placing BLUE header information into the following global fields:
9999

100-
* ``blue:fixed`` - fixed header information (at start of file)
101-
* ``blue:adjunct`` - adjunct header information (after fixed header)
102-
* ``blue:extended`` - extended header information (at end of file)
103-
* ``blue:keywords`` - user-defined key-value pairs
100+
* ``blue:fixed`` - Fixed header information (at start of file).
101+
* ``blue:adjunct`` - Adjunct header information (after fixed header).
102+
* ``blue:extended`` - Extended header information (at end of file). Note any duplicate fields will have a suffix like ``_1``, ``_2``, etc appended.
103+
* ``blue:keywords`` - User-defined key-value pairs.
104104

105105
.. autofunction:: sigmf.convert.blue.blue_to_sigmf
106106

sigmf/convert/__main__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def main() -> None:
3535
parser.add_argument("input", type=str, help="Input recording path")
3636
parser.add_argument("output", type=str, help="Output SigMF path (no extension)")
3737
parser.add_argument("-v", "--verbose", action="count", default=0, help="Increase verbosity level")
38-
parser.add_argument("-a", "--archive", action="store_true", help="Output .sigmf archive only")
39-
parser.add_argument(
38+
exclusive_group = parser.add_mutually_exclusive_group()
39+
exclusive_group.add_argument("-a", "--archive", action="store_true", help="Output .sigmf archive only")
40+
exclusive_group.add_argument(
4041
"--ncd", action="store_true", help="Output .sigmf-meta only and process as a Non-Conforming Dataset (NCD)"
4142
)
4243
parser.add_argument("--version", action="version", version=f"%(prog)s v{toolversion}")
@@ -52,16 +53,19 @@ def main() -> None:
5253
input_path = Path(args.input)
5354
output_path = Path(args.output)
5455

55-
# validate that ncd files are in same directory as input
56+
# for ncd check that input & output files are in same directory
5657
if args.ncd and input_path.parent.resolve() != output_path.parent.resolve():
5758
raise SigMFConversionError(
5859
f"NCD files must be in the same directory as input file. "
5960
f"Input: {input_path.parent.resolve()}, Output: {output_path.parent.resolve()}"
6061
)
6162

63+
# check that the output path is a file and not a directory
64+
if output_path.is_dir():
65+
raise SigMFConversionError(f"Output path must be a filename, not a directory: {output_path}")
66+
6267
# detect file type using magic bytes (same logic as fromfile())
6368
magic_bytes = get_magic_bytes(input_path, count=4, offset=0)
64-
6569
if magic_bytes == b"RIFF":
6670
# WAV file
6771
_ = wav_to_sigmf(wav_path=input_path, out_path=output_path, create_archive=args.archive, create_ncd=args.ncd)

0 commit comments

Comments
 (0)