Skip to content

Commit 2f88336

Browse files
committed
[general] Use ellipsis instead of raising exceptions where possible
1 parent e1d86d9 commit 2f88336

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

scenedetect/_cli/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ValidatedValue(ABC):
4848
@abstractmethod
4949
def value(self) -> Any:
5050
"""Get the value after validation."""
51-
raise NotImplementedError()
51+
...
5252

5353
@staticmethod
5454
@abstractmethod
@@ -58,7 +58,7 @@ def from_config(config_value: str, default: "ValidatedValue") -> "ValidatedValue
5858
Raises:
5959
OptionParseFailure: Value from config file did not meet validation constraints.
6060
"""
61-
raise NotImplementedError()
61+
...
6262

6363
def __repr__(self) -> str:
6464
return str(self.value)

scenedetect/video_stream.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class SeekError(Exception):
4949
5050
The stream is guaranteed to be left in a valid state, but the position may be reset."""
5151

52+
...
53+
5254

5355
class VideoOpenFailure(Exception):
5456
"""Raised by a backend if opening a video fails."""
@@ -98,7 +100,7 @@ def base_timecode(self) -> FrameTimecode:
98100
def BACKEND_NAME() -> str:
99101
"""Unique name used to identify this backend. Should be a static property in derived
100102
classes (`BACKEND_NAME = 'backend_identifier'`)."""
101-
raise NotImplementedError
103+
...
102104

103105
#
104106
# Abstract Properties
@@ -108,43 +110,43 @@ def BACKEND_NAME() -> str:
108110
@abstractmethod
109111
def path(self) -> Union[bytes, str]:
110112
"""Video or device path."""
111-
raise NotImplementedError
113+
...
112114

113115
@property
114116
@abstractmethod
115117
def name(self) -> Union[bytes, str]:
116118
"""Name of the video, without extension, or device."""
117-
raise NotImplementedError
119+
...
118120

119121
@property
120122
@abstractmethod
121123
def is_seekable(self) -> bool:
122124
"""True if seek() is allowed, False otherwise."""
123-
raise NotImplementedError
125+
...
124126

125127
@property
126128
@abstractmethod
127129
def frame_rate(self) -> float:
128130
"""Frame rate in frames/sec."""
129-
raise NotImplementedError
131+
...
130132

131133
@property
132134
@abstractmethod
133135
def duration(self) -> Optional[FrameTimecode]:
134136
"""Duration of the stream as a FrameTimecode, or None if non terminating."""
135-
raise NotImplementedError
137+
...
136138

137139
@property
138140
@abstractmethod
139141
def frame_size(self) -> Tuple[int, int]:
140142
"""Size of each video frame in pixels as a tuple of (width, height)."""
141-
raise NotImplementedError
143+
...
142144

143145
@property
144146
@abstractmethod
145147
def aspect_ratio(self) -> float:
146148
"""Pixel aspect ratio as a float (1.0 represents square pixels)."""
147-
raise NotImplementedError
149+
...
148150

149151
@property
150152
@abstractmethod
@@ -153,22 +155,22 @@ def position(self) -> FrameTimecode:
153155
154156
This can be interpreted as presentation time stamp, thus frame 1 corresponds
155157
to the presentation time 0. Returns 0 even if `frame_number` is 1."""
156-
raise NotImplementedError
158+
...
157159

158160
@property
159161
@abstractmethod
160162
def position_ms(self) -> float:
161163
"""Current position within stream as a float of the presentation time in
162164
milliseconds. The first frame has a PTS of 0."""
163-
raise NotImplementedError
165+
...
164166

165167
@property
166168
@abstractmethod
167169
def frame_number(self) -> int:
168170
"""Current position within stream as the frame number.
169171
170172
Will return 0 until the first frame is `read`."""
171-
raise NotImplementedError
173+
...
172174

173175
#
174176
# Abstract Methods
@@ -186,12 +188,12 @@ def read(self, decode: bool = True, advance: bool = True) -> Union[np.ndarray, b
186188
If decode = True, the decoded frame (np.ndarray), or False (bool) if end of video.
187189
If decode = False, a bool indicating if advancing to the the next frame succeeded.
188190
"""
189-
raise NotImplementedError
191+
...
190192

191193
@abstractmethod
192194
def reset(self) -> None:
193195
"""Close and re-open the VideoStream (equivalent to seeking back to beginning)."""
194-
raise NotImplementedError
196+
...
195197

196198
@abstractmethod
197199
def seek(self, target: Union[FrameTimecode, float, int]) -> None:
@@ -213,4 +215,4 @@ def seek(self, target: Union[FrameTimecode, float, int]) -> None:
213215
SeekError: An error occurs while seeking, or seeking is not supported.
214216
ValueError: `target` is not a valid value (i.e. it is negative).
215217
"""
216-
raise NotImplementedError
218+
...

0 commit comments

Comments
 (0)