Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed files are covered and no blocking issues were identified.
Pull request overview
This pull request prevents in-place files from being truncated before processing and encoding succeed.
Changes:
- Adds shared deferred-output handling.
- Updates all seven writing tools.
- Adds comprehensive CLI regression tests.
File summaries
| File | Summary |
|---|---|
tests/test_tools.py |
Adds regression coverage for output modes, failures, encodings, and links. |
srt_tools/utils.py |
Implements deferred in-place writing. |
srt_tools/srt-process |
Uses the shared output helper. |
srt_tools/srt-normalise |
Uses the shared output helper. |
srt_tools/srt-mux |
Uses the shared output helper. |
srt_tools/srt-lines-matching |
Uses the shared output helper. |
srt_tools/srt-linear-timeshift |
Uses the shared output helper. |
srt_tools/srt-fixed-timeshift |
Uses the shared output helper. |
srt_tools/srt-deduplicate |
Uses the shared output helper. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related #60.
The tools open an inplace destination with
wbbefore consuming the lazy subtitle parser. A parsing or processing error therefore leaves the original file empty. Encoding errors can also occur after truncation.Keep the inplace output path unopened until the complete output has been composed and encoded. A shared
write_outputhelper performs that final write; all seven writing tools use it, including mux's unchanged non-inplace path. Ordinary stdout and explicit output streams retain the existing encoding/fallback logic.This protects the original input from parsing, conversion, and encoding failures. It does not provide atomic replacement or protection against write errors, process termination during writing, or power loss. The destination is still opened directly, preserving the existing inode, permissions, and link-following behavior. No runtime dependencies or new Python requirements are introduced.
Validation:
srt.pybranch coverage target is 100%. This coverage target does not measure the CLI helpers.All test subtitles are synthetic. Repository maintenance is currently infrequent; no maintainer response or acceptance is assumed.