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

Function str2bool

wan/utils/utils.py:94–118  ·  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

92
93
94def str2bool(v):
95 """
96 Convert a string to a boolean.
97
98 Supported true values: 'yes', 'true', 't', 'y', '1'
99 Supported false values: 'no', 'false', 'f', 'n', '0'
100
101 Args:
102 v (str): String to convert.
103
104 Returns:
105 bool: Converted boolean value.
106
107 Raises:
108 argparse.ArgumentTypeError: If the value cannot be converted to boolean.
109 """
110 if isinstance(v, bool):
111 return v
112 v_lower = v.lower()
113 if v_lower in ('yes', 'true', 't', 'y', '1'):
114 return True
115 elif v_lower in ('no', 'false', 'f', 'n', '0'):
116 return False
117 else:
118 raise argparse.ArgumentTypeError('Boolean value expected (True/False)')
119
120import safetensors.torch
121import logging

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected