-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ignore first pac command if there are two consecutive pac commands #314
Conversation
pycaption/scc/__init__.py
Outdated
@@ -327,6 +327,9 @@ def _handle_double_command(self, word): | |||
if word == self.last_command: | |||
self.last_command = '' | |||
return True | |||
elif _is_pac_command(word) and _is_pac_command(self.last_command): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was used to ignore the second duplicate command, not the first as it seems to be your intention (I saw you wrote a test called test_skip_first_pac_command).
You go with the first command, it doesn’t find a previous double (last_command=‘’) so it returns False (as in the command is NOT a double) and it gets processed. This command is saved as last_command to be used as comparison for the next one.
Then the second command comes, it is compared to the first one (last_command=‘previousword’), it is identified as a double, (last command is being reset to avoid ignoring multiple commands) return True (the command IS a double) and doesn’t get processed.
I realise now that a better name for this would have been _is_double_command or _skip_command for it to be easier to understand
@@ -342,10 +342,9 @@ def interpret_command(self, command): | |||
|
|||
:type command: str | |||
""" | |||
self._update_positioning(command) | |||
|
|||
if command not in ["9120", "91ae", "912f", "91a1"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list could be stored in a constant to be more suggestive of what it represents, you might not remember its purpose when coming back here after a while
No description provided.