Use proper staticmethods

This commit is contained in:
ItsDrike 2021-01-14 14:55:45 +01:00
parent edd79c3a49
commit cecf4a132f
No known key found for this signature in database
GPG key ID: 252D306F545351FC

View file

@ -4,6 +4,7 @@ from src.util import color
class Print: class Print:
@staticmethod
def question(question: str, options: t.Optional[list] = None) -> None: def question(question: str, options: t.Optional[list] = None) -> None:
"""Print syntax for question with optional `options` to it""" """Print syntax for question with optional `options` to it"""
text = [f"{color.GREEN} // {question}{color.RESET}"] text = [f"{color.GREEN} // {question}{color.RESET}"]
@ -12,28 +13,34 @@ class Print:
text.append(f"{color.GREEN} # {option}{color.RESET}") text.append(f"{color.GREEN} # {option}{color.RESET}")
print("\n".join(text)) print("\n".join(text))
@staticmethod
def action(action: str) -> None: def action(action: str) -> None:
"""Print syntax for action""" """Print syntax for action"""
print(f"{color.GOLD} >> {action}{color.RESET}") print(f"{color.GOLD} >> {action}{color.RESET}")
@staticmethod
def err(text: str) -> None: def err(text: str) -> None:
"""Print syntax for error""" """Print syntax for error"""
print(f"\n{color.RED} !! {text}{color.RESET}") print(f"\n{color.RED} !! {text}{color.RESET}")
@staticmethod
def cancel(text: str) -> None: def cancel(text: str) -> None:
"""Print syntax for cancellation""" """Print syntax for cancellation"""
print(f"{color.GREY} >> {text}{color.RESET}") print(f"{color.GREY} >> {text}{color.RESET}")
@staticmethod
def comment(text: str) -> None: def comment(text: str) -> None:
"""Print syntax for comments""" """Print syntax for comments"""
print(f"{color.GREY} // {text}{color.RESET}") print(f"{color.GREY} // {text}{color.RESET}")
@staticmethod
def warning(text: str) -> None: def warning(text: str) -> None:
"""Print syntax for warnings""" """Print syntax for warnings"""
print(f"{color.YELLOW} ** {text}{color.RESET}") print(f"{color.YELLOW} ** {text}{color.RESET}")
class Input: class Input:
@staticmethod
def yes_no(question: str) -> bool: def yes_no(question: str) -> bool:
"""Ask a yes/no `question`, return True(y)/False(n)""" """Ask a yes/no `question`, return True(y)/False(n)"""
while True: while True:
@ -46,6 +53,7 @@ class Input:
else: else:
Print.err("Invalid option (Y/N)") Print.err("Invalid option (Y/N)")
@staticmethod
def multiple(question: str, options: t.List[str], abort: bool = False) -> int: def multiple(question: str, options: t.List[str], abort: bool = False) -> int:
""" """
Ask `question` with multiple `options` Ask `question` with multiple `options`
@ -69,6 +77,7 @@ class Input:
else: else:
Print.err(f"Invalid option, outside of the number range 1-{len(options)}") Print.err(f"Invalid option, outside of the number range 1-{len(options)}")
@staticmethod
def text(text: str) -> str: def text(text: str) -> str:
Print.question(text) Print.question(text)
return input(" >>") return input(" >>")