mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
ruff format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
__all__ = ["ArgParser"]
|
||||
|
||||
|
||||
from argenta.orchestrator.argparser.entity import ArgParser
|
||||
from argenta.orchestrator.argparser.entity import ArgParser
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
__all__ = ["BooleanArgument", "PositionalArgument", "OptionalArgument"]
|
||||
|
||||
|
||||
from argenta.orchestrator.argparser.arguments.models import (BooleanArgument,
|
||||
PositionalArgument,
|
||||
OptionalArgument)
|
||||
from argenta.orchestrator.argparser.arguments.models import (
|
||||
BooleanArgument,
|
||||
PositionalArgument,
|
||||
OptionalArgument,
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ class BaseArgument(ABC):
|
||||
"""
|
||||
Private. Base class for all arguments
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_string_entity(self) -> str:
|
||||
"""
|
||||
@@ -28,7 +29,7 @@ class PositionalArgument(BaseArgument):
|
||||
|
||||
|
||||
class OptionalArgument(BaseArgument):
|
||||
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
||||
def __init__(self, name: str, prefix: Literal["-", "--", "---"] = "--"):
|
||||
"""
|
||||
Public. Optional argument, must have the value
|
||||
:param name: name of the argument
|
||||
@@ -42,7 +43,7 @@ class OptionalArgument(BaseArgument):
|
||||
|
||||
|
||||
class BooleanArgument(BaseArgument):
|
||||
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
||||
def __init__(self, name: str, prefix: Literal["-", "--", "---"] = "--"):
|
||||
"""
|
||||
Public. Boolean argument, does not require a value
|
||||
:param name: name of the argument
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from argenta.orchestrator.argparser.arguments.models import (BooleanArgument,
|
||||
OptionalArgument,
|
||||
PositionalArgument)
|
||||
from argenta.orchestrator.argparser.arguments.models import (
|
||||
BooleanArgument,
|
||||
OptionalArgument,
|
||||
PositionalArgument,
|
||||
)
|
||||
|
||||
|
||||
class ArgParser:
|
||||
def __init__(self,
|
||||
processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument],
|
||||
name: str = 'Argenta',
|
||||
description: str = 'Argenta available arguments',
|
||||
epilog: str = 'github.com/koloideal/Argenta | made by kolo') -> None:
|
||||
def __init__(
|
||||
self,
|
||||
processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument],
|
||||
name: str = "Argenta",
|
||||
description: str = "Argenta available arguments",
|
||||
epilog: str = "github.com/koloideal/Argenta | made by kolo",
|
||||
) -> None:
|
||||
"""
|
||||
Public. Cmd argument parser and configurator at startup
|
||||
:param name: the name of the ArgParse instance
|
||||
@@ -22,10 +26,16 @@ class ArgParser:
|
||||
self.description = description
|
||||
self.epilog = epilog
|
||||
|
||||
self.entity: ArgumentParser = ArgumentParser(prog=name, description=description, epilog=epilog)
|
||||
self.args: list[PositionalArgument | OptionalArgument | BooleanArgument] | None = processed_args
|
||||
self.entity: ArgumentParser = ArgumentParser(
|
||||
prog=name, description=description, epilog=epilog
|
||||
)
|
||||
self.args: (
|
||||
list[PositionalArgument | OptionalArgument | BooleanArgument] | None
|
||||
) = processed_args
|
||||
|
||||
def set_args(self, *args: PositionalArgument | OptionalArgument | BooleanArgument) -> None:
|
||||
def set_args(
|
||||
self, *args: PositionalArgument | OptionalArgument | BooleanArgument
|
||||
) -> None:
|
||||
"""
|
||||
Public. Sets the arguments to be processed
|
||||
:param args: processed arguments
|
||||
@@ -46,4 +56,4 @@ class ArgParser:
|
||||
elif type(arg) is OptionalArgument:
|
||||
self.entity.add_argument(arg.get_string_entity())
|
||||
elif type(arg) is BooleanArgument:
|
||||
self.entity.add_argument(arg.get_string_entity(), action='store_true')
|
||||
self.entity.add_argument(arg.get_string_entity(), action="store_true")
|
||||
|
||||
@@ -33,4 +33,3 @@ class Orchestrator:
|
||||
return self.arg_parser.entity.parse_args()
|
||||
else:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user