Relocate libopenshot.log recovery code to exceptions.py #3839
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.
The
MainWindow
methodcreate_lock_file()
, of all things, has been repeatedly flagged as a high-complexity function. (One of four inwindows.main_window
, the remaining three beingMainWindow
'sfindAllMarkerPositions
,keyPressEvent
, and most disturbing of all,__init__
.)In the case of
create_lock_file()
, the complexity came about because, right in the middle of doing its job (creating a lock file), it went off on this long, completely-unrelated tangent where it would parse the end of the last session inlibopenshot.log
looking for stack traces.Since that has nothing to do with creating a lock file, I pulled that entire tangential block of code, plus the
tail_file()
function it (exclusively) made use of, out ofwindows.main_window
entirely. Instead I converted them both to functions inclasses.exceptions
. (Not a perfect spot, but a much better one.)Theoretically now,
exceptions.libopenshot_crash_recovery()
could even be called byapp.py
instead. Like it probably should be.(There's still too much stuff in
MainWindow
that's really application-startup stuff, IMHO. I'd remind any skeptics that, again,MainWindow.__init__()
is flagged for excessive complexity...)