cli: align directory handling with codebase style

Use warnings.warn() for errors instead of print(), show file count messages only with --verbose, and simplify user prompts. Keep error handling consistent with the original code, including traceback on exceptions.
This commit is contained in:
Cavit Erginsoy 2025-01-20 22:29:09 +00:00
parent cde50ec846
commit 2dff75fba5

View File

@ -167,13 +167,13 @@ def build_parser():
parser.add_argument(
"--prepend-punctuations",
type=str,
default="\"'¿([{-",
default="\"'""¿([{-",
help="If word-timestamps is True, merge these punctuation symbols with the next word",
)
parser.add_argument(
"--append-punctuations",
type=str,
default="\"'.。,!?:)]}、",
default="\"'.。,!?:"")]}、",
help="If word_timestamps is True, merge these punctuation symbols with the previous word",
)
parser.add_argument(
@ -273,9 +273,8 @@ def main():
)
writer(result, file_path.stem, **writer_args)
except Exception as e:
warnings.warn(f"Failed to process {file_path}: {str(e)}")
if args.get("verbose"):
traceback.print_exc()
warnings.warn(f"Failed to process {file_path}: {str(e)}")
continue
output_name = output_name or path.stem
@ -287,9 +286,8 @@ def main():
)
writer(result, output_name, **writer_args)
except Exception as e:
warnings.warn(f"Failed to process {audio_obj}: {str(e)}")
if args.get("verbose"):
traceback.print_exc()
warnings.warn(f"Failed to process {audio_obj}: {str(e)}")
if __name__ == "__main__":