MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / EscapedString

Class EscapedString

scenedetect/_cli/config.py:269–291  ·  view source on GitHub ↗

Strings that can contain escape sequences, e.g. the literal \n.

Source from the content-addressed store, hash-verified

267
268
269class EscapedString(ValidatedValue):
270 """Strings that can contain escape sequences, e.g. the literal \n."""
271
272 def __init__(self, value: str, length_limit: int = 0):
273 self._value = value.encode("utf-8").decode("unicode_escape")
274 if length_limit and len(self._value) > length_limit:
275 raise OptionParseFailure(f"Value must be no longer than {length_limit} characters.")
276
277 @property
278 def value(self) -> str:
279 """Get the value after validation."""
280 return self._value
281
282 @staticmethod
283 def from_config(
284 config_value: str, default: "EscapedString", length_limit: int = 0
285 ) -> "EscapedString":
286 try:
287 return EscapedString(config_value, length_limit)
288 except (UnicodeDecodeError, UnicodeEncodeError) as ex:
289 raise OptionParseFailure(
290 "Value must be valid UTF-8 string with escape characters."
291 ) from ex
292
293
294class EscapedChar(EscapedString):

Callers 2

from_configMethod · 0.85
config.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected