slice([starts_before][, starts_after][, ends_before][, ends_after]) \ -> SubRipFile clone All arguments are optional, and should be coercible to SubRipTime object. It reduce the set of subtitles to those that match match given time constraints. The
(self, starts_before=None, starts_after=None, ends_before=None,
ends_after=None)
| 60 | eol = property(_get_eol, _set_eol) |
| 61 | |
| 62 | def slice(self, starts_before=None, starts_after=None, ends_before=None, |
| 63 | ends_after=None): |
| 64 | """ |
| 65 | slice([starts_before][, starts_after][, ends_before][, ends_after]) \ |
| 66 | -> SubRipFile clone |
| 67 | |
| 68 | All arguments are optional, and should be coercible to SubRipTime |
| 69 | object. |
| 70 | |
| 71 | It reduce the set of subtitles to those that match match given time |
| 72 | constraints. |
| 73 | |
| 74 | The returned set is a clone, but still contains references to original |
| 75 | subtitles. So if you shift this returned set, subs contained in the |
| 76 | original SubRipFile instance will be altered too. |
| 77 | |
| 78 | Example: |
| 79 | >>> subs.slice(ends_after={'seconds': 20}).shift(seconds=2) |
| 80 | """ |
| 81 | clone = copy(self) |
| 82 | |
| 83 | if starts_before: |
| 84 | clone.data = (i for i in clone.data if i.start < starts_before) |
| 85 | if starts_after: |
| 86 | clone.data = (i for i in clone.data if i.start > starts_after) |
| 87 | if ends_before: |
| 88 | clone.data = (i for i in clone.data if i.end < ends_before) |
| 89 | if ends_after: |
| 90 | clone.data = (i for i in clone.data if i.end > ends_after) |
| 91 | |
| 92 | clone.data = list(clone.data) |
| 93 | return clone |
| 94 | |
| 95 | def at(self, timestamp=None, **kwargs): |
| 96 | """ |
no test coverage detected