cli.console: refactor and move into sub-package #6496
Merged
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.
Some more changes in preparation for #6449. Doing this in a sequence of PRs instead of just one giant one...
streamlink_cli.console
module into a sub-package and move theConsoleUserInputRequester
into its own module.ConsoleOutput._write()
method(s), so adding themsg_status()
method in the future is easier (used for the download progress status line at the bottom)ConsoleOutputStream
, which wrapssys.stdout
/sys.stderr
and simply passes through all attribute lookups. This is necessary so we can intercept writes to stdout/stderr which we don't control via theConsoleOutput
, e.g. in Streamlink's dependencies. Otherwise, random writes to these text streams would break the status line at the bottom.streamlink_cli.progress
into thestreamlink_cli.console
sub-packageprogress
module (again, this has already been moved twice in the past)Uncommitted and unfinished changes on top of this branch that will come in follow-up PRs:
Progress
and send messages toConsoleOutput.msg_status()
instead of writing to a stream object (sys.stderr
) directly and adding a carriage-return character with white-space padding at the end of the lineStreamRunner
and its setup due to theProgress
setup changes (rewriting tests is a bit annoying)ConsoleOutputStream
(with subclasses) which handle regular messages and status messages, depending on available terminal features (ANSI control sequences, Windows console, or neither).ConsoleOutputStreamWindows
class including its detection is still unfinished and currently falls back to the default writer implementation which does not support status messages--progress=force
doesn't make sense anymore when the required writer features are not supported, as we're now merging the regular and status messages into one stream. An idea I have is making it write the status messages as regular messages, but this would require a slower time interval by theProgress
class in that case, as it updates four times per second. Basically another (minor)Progress
refactor.