Update formating

This commit is contained in:
linarphy 2024-06-05 17:49:08 +02:00
parent 8fdb78b908
commit 94edd899d0
No known key found for this signature in database
GPG key ID: E61920135EFF2295
4 changed files with 20 additions and 14 deletions

View file

@ -1,7 +1,13 @@
from command_parser.option import Option from command_parser.option import Option
class Flag(Option): class Flag(Option):
def __init__(self, name: str, default: bool = False, single_char: str | None = None) -> None: def __init__(
self,
name: str,
default: bool = False,
single_char: str | None = None,
) -> None:
super(Flag, self).__init__(name, single_char) super(Flag, self).__init__(name, single_char)
self.value = default self.value = default

View file

@ -1,10 +1,11 @@
from command_parser import logger from command_parser import logger
class Option: class Option:
def __init__(self, name: str, single_char: str | None = None) -> None: def __init__(
logger.debug( self, name: str, single_char: str | None = None
_("creating new option with the name {name}") ) -> None:
) logger.debug(_("creating new option with the name {name}"))
if single_char is None: if single_char is None:
logger.debug( logger.debug(
_( _(
@ -18,12 +19,10 @@ class Option:
_( _(
"char representation should be only one char " "char representation should be only one char "
+ "long" + "long"
) )
) )
logger.debug( logger.debug(
_( _("single char {char} defined").format(char=single_char)
"single char {char} defined"
).format(char = single_char)
) )
self.name = name self.name = name
self.single_char = single_char self.single_char = single_char

View file

@ -3,6 +3,7 @@ from command_parser import logger
from command_parser.flag import Flag from command_parser.flag import Flag
from command_parser.value import Value from command_parser.value import Value
def parse(line: str, flags: list[Flag], values: list[Value]): def parse(line: str, flags: list[Flag], values: list[Value]):
""" """
parse a command line parser parse a command line parser
@ -46,7 +47,7 @@ def parse(line: str, flags: list[Flag], values: list[Value]):
index += 1 index += 1
for value in values: for value in values:
if value.long() == element[: len(value.long())]: if value.long() == element[: len(value.long())]:
value.apply(element[len(value.long()):]) value.apply(element[len(value.long()) :])
index += 1 index += 1
except IndexError: except IndexError:
logger.warning(_("empty value")) logger.warning(_("empty value"))

View file

@ -15,14 +15,14 @@ class Value(Option):
if allowlist is None: if allowlist is None:
logger.debug( logger.debug(
_("every values is accepted for {option}").format( _("every values is accepted for {option}").format(
option = self.name, option=self.name,
) )
) )
else: else:
logger.debug( logger.debug(
_( _(
"only some values is accepted for {option}".format( "only some values is accepted for {option}".format(
option = self.name option=self.name
) )
) )
) )
@ -43,7 +43,7 @@ class Value(Option):
"{value} is not an accepted value for the " "{value} is not an accepted value for the "
+ "option {option}" + "option {option}"
).format( ).format(
value = value, value=value,
option = self.name, option=self.name,
) )
) )