Skip to content

Instantly share code, notes, and snippets.

@FernandoCelmer
Last active January 22, 2023 23:33
Show Gist options
  • Save FernandoCelmer/803d92e0d00c0a7afc2aa10586e1d185 to your computer and use it in GitHub Desktop.
Save FernandoCelmer/803d92e0d00c0a7afc2aa10586e1d185 to your computer and use it in GitHub Desktop.
is_bool.py
def is_bool(self, value: str) -> str:
bool_list = [
("on", True),
("true", True),
("True", True),
("1", True),
("yes", True),
("ok", True),
("y", True),
("Y", True),
("of", False),
("false", False),
("False", False),
("0", False),
("no", False),
("not", False),
("n", False),
("N", False)
]
for item in bool_list:
if value in item:
return item[1]
return value
def setup_options(self):
for option in self.list_option:
if hasattr(self.arguments, option):
setattr(self, option, self.is_bool(getattr(self.arguments, option)))
else:
setattr(self, option, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment