MCPcopy Create free account
hub / github.com/DanielShalam/BPA / bool_flag

Function bool_flag

utils.py:239–250  ·  view source on GitHub ↗

Parse boolean arguments from the command line.

(s)

Source from the content-addressed store, hash-verified

237
238
239def bool_flag(s):
240 """
241 Parse boolean arguments from the command line.
242 """
243 FALSY_STRINGS = {"off", "false", "0"}
244 TRUTHY_STRINGS = {"on", "true", "1"}
245 if s.lower() in FALSY_STRINGS:
246 return False
247 elif s.lower() in TRUTHY_STRINGS:
248 return True
249 else:
250 raise argparse.ArgumentTypeError("invalid value for a boolean flag")
251
252
253def print_and_log(results: dict, n: int = 0):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected