Last active
January 22, 2023 23:33
-
-
Save FernandoCelmer/803d92e0d00c0a7afc2aa10586e1d185 to your computer and use it in GitHub Desktop.
is_bool.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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