MCPcopy
hub / github.com/csev/py4e / slice

Method slice

lectures/srt-split/pysrt/srtfile.py:62–93  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 15

atMethod · 0.95
upFunction · 0.80
enterFunction · 0.80
selectFunction · 0.80
changeFunction · 0.80
getRangeFunction · 0.80
readInputFunction · 0.80
indentLineFunction · 0.80
measureLineFunction · 0.80
codemirrorepl.jsFile · 0.80
span_Function · 0.80
copyStylesFunction · 0.80

Calls 1

listFunction · 0.85

Tested by

no test coverage detected