MCPcopy Create free account
hub / github.com/MeiGen-AI/InfiniteTalk / str2bool

Function str2bool

wan/utils/utils.py:31–55  ·  view source on GitHub ↗

Convert a string to a boolean. Supported true values: 'yes', 'true', 't', 'y', '1' Supported false values: 'no', 'false', 'f', 'n', '0' Args: v (str): String to convert. Returns: bool: Converted boolean value. Raises: argparse.ArgumentTypeError: I

(v)

Source from the content-addressed store, hash-verified

29
30
31def str2bool(v):
32 """
33 Convert a string to a boolean.
34
35 Supported true values: 'yes', 'true', 't', 'y', '1'
36 Supported false values: 'no', 'false', 'f', 'n', '0'
37
38 Args:
39 v (str): String to convert.
40
41 Returns:
42 bool: Converted boolean value.
43
44 Raises:
45 argparse.ArgumentTypeError: If the value cannot be converted to boolean.
46 """
47 if isinstance(v, bool):
48 return v
49 v_lower = v.lower()
50 if v_lower in ('yes', 'true', 't', 'y', '1'):
51 return True
52 elif v_lower in ('no', 'false', 'f', 'n', '0'):
53 return False
54 else:
55 raise argparse.ArgumentTypeError('Boolean value expected (True/False)')
56
57def cache_video(tensor,
58 save_file=None,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected