mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
ruff format
This commit is contained in:
@@ -8,17 +8,24 @@ class PredefinedFlags:
|
||||
"""
|
||||
Public. A dataclass with predefined flags and most frequently used flags for quick use
|
||||
"""
|
||||
HELP = Flag(name='help', possible_values=False)
|
||||
SHORT_HELP = Flag(name='H', prefix='-', possible_values=False)
|
||||
|
||||
INFO = Flag(name='info', possible_values=False)
|
||||
SHORT_INFO = Flag(name='I', prefix='-', possible_values=False)
|
||||
HELP = Flag(name="help", possible_values=False)
|
||||
SHORT_HELP = Flag(name="H", prefix="-", possible_values=False)
|
||||
|
||||
ALL = Flag(name='all', possible_values=False)
|
||||
SHORT_ALL = Flag(name='A', prefix='-', possible_values=False)
|
||||
INFO = Flag(name="info", possible_values=False)
|
||||
SHORT_INFO = Flag(name="I", prefix="-", possible_values=False)
|
||||
|
||||
HOST = Flag(name='host', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
|
||||
SHORT_HOST = Flag(name='H', prefix='-', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
|
||||
ALL = Flag(name="all", possible_values=False)
|
||||
SHORT_ALL = Flag(name="A", prefix="-", possible_values=False)
|
||||
|
||||
PORT = Flag(name='port', possible_values=re.compile(r'^\d{1,5}$'))
|
||||
SHORT_PORT = Flag(name='P', prefix='-', possible_values=re.compile(r'^\d{1,5}$'))
|
||||
HOST = Flag(
|
||||
name="host", possible_values=re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
|
||||
)
|
||||
SHORT_HOST = Flag(
|
||||
name="H",
|
||||
prefix="-",
|
||||
possible_values=re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"),
|
||||
)
|
||||
|
||||
PORT = Flag(name="port", possible_values=re.compile(r"^\d{1,5}$"))
|
||||
SHORT_PORT = Flag(name="P", prefix="-", possible_values=re.compile(r"^\d{1,5}$"))
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
from typing import Literal, Pattern
|
||||
|
||||
|
||||
|
||||
class BaseFlag:
|
||||
def __init__(self, name: str,
|
||||
prefix: Literal['-', '--', '---'] = '--') -> None:
|
||||
def __init__(self, name: str, prefix: Literal["-", "--", "---"] = "--") -> None:
|
||||
"""
|
||||
Private. Base class for flags
|
||||
:param name: the name of the flag
|
||||
@@ -41,9 +39,12 @@ class BaseFlag:
|
||||
|
||||
|
||||
class Flag(BaseFlag):
|
||||
def __init__(self, name: str,
|
||||
prefix: Literal['-', '--', '---'] = '--',
|
||||
possible_values: list[str] | Pattern[str] | False = True) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
prefix: Literal["-", "--", "---"] = "--",
|
||||
possible_values: list[str] | Pattern[str] | False = True,
|
||||
) -> None:
|
||||
"""
|
||||
Public. The entity of the flag being registered for subsequent processing
|
||||
:param name: The name of the flag
|
||||
@@ -85,9 +86,9 @@ class Flag(BaseFlag):
|
||||
|
||||
|
||||
class InputFlag(BaseFlag):
|
||||
def __init__(self, name: str,
|
||||
prefix: Literal['-', '--', '---'] = '--',
|
||||
value: str = None):
|
||||
def __init__(
|
||||
self, name: str, prefix: Literal["-", "--", "---"] = "--", value: str = None
|
||||
):
|
||||
"""
|
||||
Public. The entity of the flag of the entered command
|
||||
:param name: the name of the input flag
|
||||
@@ -114,5 +115,7 @@ class InputFlag(BaseFlag):
|
||||
self._flag_value = value
|
||||
|
||||
def __eq__(self, other) -> bool:
|
||||
return self.get_string_entity() == other.get_string_entity() and self.get_value() == other.get_value()
|
||||
|
||||
return (
|
||||
self.get_string_entity() == other.get_string_entity()
|
||||
and self.get_value() == other.get_value()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user