argenta 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
argenta/app/entity.py CHANGED
@@ -3,13 +3,10 @@ from inspect import getfullargspec
3
3
 
4
4
  from ..command.entity import Command
5
5
  from ..router.entity import Router
6
- from ..command.input_comand.entity import InputCommand
7
- from ..command.input_comand.exceptions import (UnprocessedInputFlagException,
8
- InvalidInputFlagsHandlerHasBeenAlreadyCreatedException,
9
- IncorrectNumberOfHandlerArgsException,
10
- UnknownCommandHandlerHasBeenAlreadyCreatedException,
11
- RepeatedInputFlagsException,
12
- RepeatedInputFlagsHandlerHasBeenAlreadyCreatedException)
6
+ from ..command.exceptions import (UnprocessedInputFlagException,
7
+ IncorrectNumberOfHandlerArgsException,
8
+ RepeatedInputFlagsException,
9
+ EmptyInputCommandException)
13
10
  from .exceptions import (InvalidRouterInstanceException,
14
11
  InvalidDescriptionMessagePatternException,
15
12
  NoRegisteredRoutersException,
@@ -47,12 +44,12 @@ class App:
47
44
  self.repeat_command_groups = repeat_command_groups
48
45
 
49
46
  self._routers: list[Router] = []
50
- self._invalid_input_flags_handler: Callable[[str], None] | None = None
51
- self._repeated_input_flags_handler: Callable[[str], None] | None = None
52
- self._unknown_command_handler: Callable[[Command], None] | None = None
53
- self._registered_router_entities: list[dict[str, str | list[dict[str, Callable[[], None] | Command]] | Router]] = []
54
- self._app_main_router: Router | None = None
55
47
  self._description_message_pattern: str = '[{command}] *=*=* {description}'
48
+ self._registered_router_entities: list[dict[str, str | list[dict[str, Callable[[], None] | Command]] | Router]] = []
49
+ self._invalid_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'Incorrect flag syntax: "{raw_command}"')
50
+ self._repeated_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'Repeated input flags: "{raw_command}"')
51
+ self._empty_input_command_handler: Callable[[], None] = lambda: print_func(f'Empty input command')
52
+ self._unknown_command_handler: Callable[[Command], None] = lambda command: print_func(f"Unknown command: {command.get_string_entity()}")
56
53
 
57
54
 
58
55
  def start_polling(self) -> None:
@@ -74,34 +71,42 @@ class App:
74
71
  raw_command: str = input()
75
72
 
76
73
  try:
77
- input_command: InputCommand = InputCommand.parse(raw_command=raw_command)
74
+ input_command: Command = Command.parse_input_command(raw_command=raw_command)
78
75
  except UnprocessedInputFlagException:
79
76
  self.print_func(self.line_separate)
80
- if self._invalid_input_flags_handler:
81
- self._invalid_input_flags_handler(raw_command)
82
- else:
83
- self.print_func(f'Incorrect flag syntax: "{raw_command}"')
77
+ self._invalid_input_flags_handler(raw_command)
84
78
  self.print_func(self.line_separate)
79
+
85
80
  if not self.repeat_command_groups:
86
81
  self.print_func(self.prompt)
87
82
  continue
83
+
88
84
  except RepeatedInputFlagsException:
89
85
  self.print_func(self.line_separate)
90
- if self._repeated_input_flags_handler:
91
- self._repeated_input_flags_handler(raw_command)
92
- else:
93
- self.print_func(f'Repeated input flags: "{raw_command}"')
86
+ self._repeated_input_flags_handler(raw_command)
94
87
  self.print_func(self.line_separate)
88
+
95
89
  if not self.repeat_command_groups:
96
90
  self.print_func(self.prompt)
97
91
  continue
98
92
 
99
- self._checking_command_for_exit_command(input_command.get_string_entity())
100
- self.print_func(self.line_separate)
93
+ except EmptyInputCommandException:
94
+ self.print_func(self.line_separate)
95
+ self._empty_input_command_handler()
96
+ self.print_func(self.line_separate)
101
97
 
98
+ if not self.repeat_command_groups:
99
+ self.print_func(self.prompt)
100
+ continue
101
+
102
+ self._check_command_for_exit_command(input_command.get_string_entity())
103
+
104
+ self.print_func(self.line_separate)
102
105
  is_unknown_command: bool = self._check_is_command_unknown(input_command)
103
106
 
104
107
  if is_unknown_command:
108
+ self.print_func(self.line_separate)
109
+ self.print_func(self.command_group_description_separate)
105
110
  if not self.repeat_command_groups:
106
111
  self.print_func(self.prompt)
107
112
  continue
@@ -125,52 +130,35 @@ class App:
125
130
 
126
131
  def set_description_message_pattern(self, pattern: str) -> None:
127
132
  try:
128
- pattern.format(command='command',
129
- description='description')
133
+ pattern.format(command='command', description='description')
130
134
  except KeyError:
131
135
  raise InvalidDescriptionMessagePatternException(pattern)
132
- self._description_message_pattern: str = pattern
136
+ else:
137
+ self._description_message_pattern: str = pattern
133
138
 
134
139
 
135
140
  def set_invalid_input_flags_handler(self, handler: Callable[[str], None]) -> None:
136
- if self._invalid_input_flags_handler:
137
- raise InvalidInputFlagsHandlerHasBeenAlreadyCreatedException()
141
+ args = getfullargspec(handler).args
142
+ if len(args) != 1:
143
+ raise IncorrectNumberOfHandlerArgsException()
138
144
  else:
139
- args = getfullargspec(handler).args
140
- if len(args) != 1:
141
- raise IncorrectNumberOfHandlerArgsException()
142
- else:
143
- self._invalid_input_flags_handler = handler
145
+ self._invalid_input_flags_handler = handler
144
146
 
145
147
 
146
148
  def set_repeated_input_flags_handler(self, handler: Callable[[str], None]) -> None:
147
- if self._repeated_input_flags_handler:
148
- raise RepeatedInputFlagsHandlerHasBeenAlreadyCreatedException()
149
+ args = getfullargspec(handler).args
150
+ if len(args) != 1:
151
+ raise IncorrectNumberOfHandlerArgsException()
149
152
  else:
150
- args = getfullargspec(handler).args
151
- if len(args) != 1:
152
- raise IncorrectNumberOfHandlerArgsException()
153
- else:
154
- self._repeated_input_flags_handler = handler
153
+ self._repeated_input_flags_handler = handler
155
154
 
156
155
 
157
156
  def set_unknown_command_handler(self, handler: Callable[[str], None]) -> None:
158
- if self._unknown_command_handler:
159
- raise UnknownCommandHandlerHasBeenAlreadyCreatedException()
157
+ args = getfullargspec(handler).args
158
+ if len(args) != 1:
159
+ raise IncorrectNumberOfHandlerArgsException()
160
160
  else:
161
- args = getfullargspec(handler).args
162
- if len(args) != 1:
163
- raise IncorrectNumberOfHandlerArgsException()
164
- else:
165
- self._unknown_command_handler = handler
166
-
167
-
168
- def get_all_app_commands(self) -> list[str]:
169
- all_commands: list[str] = []
170
- for router in self._routers:
171
- all_commands.extend(router.get_all_commands())
172
-
173
- return all_commands
161
+ self._unknown_command_handler = handler
174
162
 
175
163
 
176
164
  def include_router(self, router: Router) -> None:
@@ -214,7 +202,7 @@ class App:
214
202
  raise RepeatedCommandInDifferentRoutersException()
215
203
 
216
204
 
217
- def _checking_command_for_exit_command(self, command: str):
205
+ def _check_command_for_exit_command(self, command: str):
218
206
  if command.lower() == self.exit_command.lower():
219
207
  if self.ignore_exit_command_register:
220
208
  self.print_func(self.farewell_message)
@@ -235,14 +223,7 @@ class App:
235
223
  else:
236
224
  if command_entity['command'].get_string_entity() == command.get_string_entity():
237
225
  return False
238
-
239
- if self._unknown_command_handler:
240
- self._unknown_command_handler(command)
241
- else:
242
- print(f"Unknown command: {command.get_string_entity()}")
243
-
244
- self.print_func(self.line_separate)
245
- self.print_func(self.command_group_description_separate)
226
+ self._unknown_command_handler(command)
246
227
  return True
247
228
 
248
229
 
argenta/command/entity.py CHANGED
@@ -2,11 +2,18 @@ from .params.flag.entity import Flag
2
2
  from .params.flag.flags_group.entity import FlagsGroup
3
3
  from .exceptions import (InvalidCommandInstanceException,
4
4
  InvalidDescriptionInstanceException,
5
- InvalidFlagsInstanceException)
6
- from .params.flag.input_flag.entity import InputFlag
5
+ InvalidFlagsInstanceException,
6
+ UnprocessedInputFlagException,
7
+ RepeatedInputFlagsException,
8
+ EmptyInputCommandException)
7
9
 
10
+ from typing import Generic, TypeVar
8
11
 
9
- class Command:
12
+
13
+ T = TypeVar('T')
14
+
15
+
16
+ class Command(Generic[T]):
10
17
  def __init__(self, command: str,
11
18
  description: str | None = None,
12
19
  flags: Flag | FlagsGroup | None = None):
@@ -14,11 +21,13 @@ class Command:
14
21
  self._description = description
15
22
  self._flags: FlagsGroup | None = flags if isinstance(flags, FlagsGroup) else FlagsGroup([flags]) if isinstance(flags, Flag) else flags
16
23
 
17
- self._input_flags: InputFlag | FlagsGroup | None = None
24
+ self._input_flags: FlagsGroup | None = None
25
+
18
26
 
19
27
  def get_string_entity(self):
20
28
  return self._command
21
29
 
30
+
22
31
  def get_description(self):
23
32
  if not self._description:
24
33
  description = f'description for "{self._command}" command'
@@ -26,22 +35,22 @@ class Command:
26
35
  else:
27
36
  return self._description
28
37
 
29
- def get_flags(self):
38
+
39
+ def get_registered_flags(self):
30
40
  return self._flags
31
41
 
32
- def set_command(self, command: str):
33
- self._command = command
34
42
 
35
43
  def validate_commands_params(self):
36
44
  if not isinstance(self._command, str):
37
45
  raise InvalidCommandInstanceException(self._command)
38
46
  if not isinstance(self._description, str):
39
47
  raise InvalidDescriptionInstanceException()
40
- if not any([(isinstance(self._flags, Flag), isinstance(self._flags, FlagsGroup)), not self._flags]):
48
+ if not any([(isinstance(self._flags, FlagsGroup)), not self._flags]):
41
49
  raise InvalidFlagsInstanceException
42
50
 
43
- def validate_input_flag(self, flag: InputFlag):
44
- registered_flags: FlagsGroup | Flag | None = self._flags
51
+
52
+ def validate_input_flag(self, flag: Flag):
53
+ registered_flags: FlagsGroup | None = self.get_registered_flags()
45
54
  if registered_flags:
46
55
  if isinstance(registered_flags, Flag):
47
56
  if registered_flags.get_string_entity() == flag.get_string_entity():
@@ -57,4 +66,60 @@ class Command:
57
66
  return False
58
67
 
59
68
 
69
+ def set_input_flags(self, input_flags: FlagsGroup):
70
+ self._input_flags = input_flags
71
+
72
+ def get_input_flags(self) -> FlagsGroup:
73
+ return self._input_flags
74
+
75
+ @staticmethod
76
+ def parse_input_command(raw_command: str) -> 'Command[T]':
77
+ if not raw_command:
78
+ raise EmptyInputCommandException()
79
+ list_of_tokens = raw_command.split()
80
+ command = list_of_tokens[0]
81
+ list_of_tokens.pop(0)
82
+
83
+ flags: FlagsGroup = FlagsGroup()
84
+ current_flag_name = None
85
+ current_flag_value = None
86
+ for _ in list_of_tokens:
87
+ if _.startswith('-'):
88
+ flag_prefix_last_symbol_index = _.rfind('-')
89
+ if current_flag_name or len(_) < 2 or len(_[:flag_prefix_last_symbol_index]) > 3:
90
+ raise UnprocessedInputFlagException()
91
+ else:
92
+ current_flag_name = _
93
+ else:
94
+ if not current_flag_name:
95
+ raise UnprocessedInputFlagException()
96
+ else:
97
+ current_flag_value = _
98
+ if current_flag_name and current_flag_value:
99
+ flag_prefix_last_symbol_index = current_flag_name.rfind('-')
100
+ flag_prefix = current_flag_name[:flag_prefix_last_symbol_index]
101
+ flag_name = current_flag_name[flag_prefix_last_symbol_index:]
102
+
103
+ input_flag = Flag(flag_name=flag_name,
104
+ flag_prefix=flag_prefix)
105
+ input_flag.set_value(current_flag_value)
106
+
107
+ all_flags = [x.get_string_entity() for x in flags.get_flags()]
108
+ if input_flag.get_string_entity() not in all_flags:
109
+ flags.add_flag(input_flag)
110
+ else:
111
+ raise RepeatedInputFlagsException(input_flag)
112
+
113
+ current_flag_name = None
114
+ current_flag_value = None
115
+ if any([current_flag_name, current_flag_value]):
116
+ raise UnprocessedInputFlagException()
117
+ if len(flags.get_flags()) == 0:
118
+ return Command(command=command)
119
+ else:
120
+ input_command = Command(command=command)
121
+ input_command.set_input_flags(flags)
122
+ return input_command
123
+
124
+
60
125
 
@@ -1,3 +1,6 @@
1
+ from .params.flag.entity import Flag
2
+
3
+
1
4
  class InvalidCommandInstanceException(Exception):
2
5
  def __str__(self):
3
6
  return "Invalid Command Instance"
@@ -11,3 +14,26 @@ class InvalidDescriptionInstanceException(Exception):
11
14
  class InvalidFlagsInstanceException(Exception):
12
15
  def __str__(self):
13
16
  return "Invalid Flags Instance"
17
+
18
+
19
+ class UnprocessedInputFlagException(Exception):
20
+ def __str__(self):
21
+ return "Unprocessed Input Flags"
22
+
23
+
24
+ class RepeatedInputFlagsException(Exception):
25
+ def __init__(self, flag: Flag):
26
+ self.flag = flag
27
+ def __str__(self):
28
+ return ("Repeated Input Flags\n"
29
+ f"Duplicate flag was detected in the input: '{self.flag.get_string_entity()}'")
30
+
31
+
32
+ class IncorrectNumberOfHandlerArgsException(Exception):
33
+ def __str__(self):
34
+ return "Incorrect Input Flags Handler has incorrect number of arguments"
35
+
36
+
37
+ class EmptyInputCommandException(Exception):
38
+ def __str__(self):
39
+ return "Input Command is empty"
@@ -1,11 +1,11 @@
1
- from typing import Literal
1
+ from typing import Literal, Pattern
2
2
 
3
3
 
4
4
  class Flag:
5
5
  def __init__(self, flag_name: str,
6
6
  flag_prefix: Literal['-', '--', '---'] = '-',
7
7
  ignore_flag_value_register: bool = False,
8
- possible_flag_values: list[str] = False):
8
+ possible_flag_values: list[str] | Pattern[str] = False):
9
9
  self._flag_name = flag_name
10
10
  self._flag_prefix = flag_prefix
11
11
  self.possible_flag_values = possible_flag_values
@@ -30,7 +30,14 @@ class Flag:
30
30
  self._value = value
31
31
 
32
32
  def validate_input_flag_value(self, input_flag_value: str):
33
- if self.possible_flag_values:
33
+ if isinstance(self.possible_flag_values, Pattern):
34
+ is_valid = bool(self.possible_flag_values.match(input_flag_value))
35
+ if bool(is_valid):
36
+ return True
37
+ else:
38
+ return False
39
+
40
+ if isinstance(self.possible_flag_values, list):
34
41
  if self.ignore_flag_value_register:
35
42
  if input_flag_value.lower() in [x.lower() for x in self.possible_flag_values]:
36
43
  return True
@@ -1,18 +1,17 @@
1
1
  from argenta.command.params.flag.entity import Flag
2
- from argenta.command.params.flag.input_flag.entity import InputFlag
3
2
 
4
3
 
5
4
  class FlagsGroup:
6
- def __init__(self, flags: list[Flag | InputFlag] = None):
7
- self._flags: list[Flag | InputFlag] = [] if not flags else flags
5
+ def __init__(self, flags: list[Flag] = None):
6
+ self._flags: list[Flag] = [] if not flags else flags
8
7
 
9
8
  def get_flags(self):
10
9
  return self._flags
11
10
 
12
- def add_flag(self, flag: Flag | InputFlag):
11
+ def add_flag(self, flag: Flag):
13
12
  self._flags.append(flag)
14
13
 
15
- def add_flags(self, flags: list[Flag | InputFlag]):
14
+ def add_flags(self, flags: list[Flag]):
16
15
  self._flags.extend(flags)
17
16
 
18
17
  def __iter__(self):
argenta/router/entity.py CHANGED
@@ -1,7 +1,6 @@
1
1
  from typing import Callable, Any
2
2
  from inspect import getfullargspec
3
3
  from ..command.entity import Command
4
- from ..command.input_comand.entity import InputCommand
5
4
  from ..command.params.flag.flags_group.entity import FlagsGroup
6
5
  from ..router.exceptions import (RepeatedCommandException, RepeatedFlagNameException,
7
6
  TooManyTransferredArgsException,
@@ -53,12 +52,12 @@ class Router:
53
52
  return wrapper
54
53
 
55
54
 
56
- def input_command_handler(self, input_command: InputCommand):
55
+ def input_command_handler(self, input_command: Command):
57
56
  input_command_name: str = input_command.get_string_entity()
58
57
  input_command_flags: FlagsGroup = input_command.get_input_flags()
59
58
  for command_entity in self._command_entities:
60
59
  if input_command_name.lower() == command_entity['command'].get_string_entity().lower():
61
- if command_entity['command'].get_flags():
60
+ if command_entity['command'].get_registered_flags():
62
61
  if input_command_flags:
63
62
  for flag in input_command_flags:
64
63
  is_valid = command_entity['command'].validate_input_flag(flag)
@@ -90,7 +89,7 @@ class Router:
90
89
  if command_name.lower() in [x.lower() for x in self.get_all_commands()]:
91
90
  raise RepeatedCommandException()
92
91
 
93
- flags: FlagsGroup = command.get_flags()
92
+ flags: FlagsGroup = command.get_registered_flags()
94
93
  if flags:
95
94
  flags_name: list = [x.get_string_entity().lower() for x in flags]
96
95
  if len(set(flags_name)) < len(flags_name):
@@ -99,7 +98,7 @@ class Router:
99
98
 
100
99
  @staticmethod
101
100
  def _validate_func_args(command: Command, func: Callable):
102
- registered_args = command.get_flags()
101
+ registered_args = command.get_registered_flags()
103
102
  transferred_args = getfullargspec(func).args
104
103
  if registered_args and transferred_args:
105
104
  if len(transferred_args) != 1:
@@ -148,6 +147,6 @@ class Router:
148
147
  def get_all_flags(self) -> list[FlagsGroup]:
149
148
  all_flags: list[FlagsGroup] = []
150
149
  for command_entity in self._command_entities:
151
- all_flags.append(command_entity['command'].get_flags())
150
+ all_flags.append(command_entity['command'].get_registered_flags())
152
151
 
153
152
  return all_flags
@@ -1,6 +1,3 @@
1
- from ..command.params.flag.input_flag.entity import InputFlag
2
-
3
-
4
1
  class InvalidDescriptionInstanceException(Exception):
5
2
  def __str__(self):
6
3
  return "Invalid Description Instance"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: argenta
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: python library for creating custom shells
5
5
  License: MIT
6
6
  Author: kolo
@@ -0,0 +1,19 @@
1
+ argenta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ argenta/app/__init__.py,sha256=yOt8-2lholVRUtLPwAXuemh115q1unP1PKLBR_7cd4E,152
3
+ argenta/app/entity.py,sha256=NLc6_5NVeNNkenDHiX_WcZsBpaXImolZPBhdC42ofCM,11183
4
+ argenta/app/exceptions.py,sha256=7_p_5NS_paLAU3xGAWufpfkdTxRx07T2zWYzGKdlCMs,1086
5
+ argenta/command/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ argenta/command/entity.py,sha256=hY7QL7bt8p9wDTeHXzL8zPc6e4_8MaNR8H3ELgf-t0M,4853
7
+ argenta/command/exceptions.py,sha256=vr8SMHwIHkcsw5rK-HBy7a8QQIjLCkGZKSY-E066NBc,1084
8
+ argenta/command/params/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ argenta/command/params/flag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ argenta/command/params/flag/entity.py,sha256=wkbbAzpFWacHcoulZcWhY-mudSpQA9deVsGCHqup4Bc,1740
11
+ argenta/command/params/flag/flags_group/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ argenta/command/params/flag/flags_group/entity.py,sha256=vicuhXVyf9szr7mt1jokfjBCnaCac_HE8GUM_PJqMMM,591
13
+ argenta/router/__init__.py,sha256=ZedowNgGR9OphLSg9fXp6-uvjyf23rbq-rEtuHScAIM,87
14
+ argenta/router/entity.py,sha256=xW33MI_INLe7j9lwmwMzvzgiGqLz5pcw4_TwuOYxJqI,6250
15
+ argenta/router/exceptions.py,sha256=l9rD_ySeWLYBDPv7R8XYMBWpAE2QOKjYAcZPcTjfUMI,981
16
+ argenta-0.3.4.dist-info/LICENSE,sha256=zmqoGh2n5rReBv4s8wPxF_gZEZDgauJYSPMuPczgOiU,1082
17
+ argenta-0.3.4.dist-info/METADATA,sha256=vaV77RsmdQYSKXqoUGVeseWvxj9DNpB2iXLIbW50j0w,12638
18
+ argenta-0.3.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
19
+ argenta-0.3.4.dist-info/RECORD,,
File without changes
@@ -1,66 +0,0 @@
1
- from ..input_comand.exceptions import UnprocessedInputFlagException, RepeatedInputFlagsException
2
- from ..entity import Command
3
- from ..params.flag.flags_group.entity import FlagsGroup
4
- from ..params.flag.input_flag.entity import InputFlag
5
-
6
- from typing import Generic, TypeVar
7
-
8
-
9
- T = TypeVar('T')
10
-
11
-
12
- class InputCommand(Command, Generic[T]):
13
- def set_input_flags(self, input_flags: FlagsGroup):
14
- self._input_flags = input_flags
15
-
16
- def get_input_flags(self) -> FlagsGroup:
17
- return self._input_flags
18
-
19
- @staticmethod
20
- def parse(raw_command: str) -> 'InputCommand[T]':
21
- list_of_tokens = raw_command.split()
22
- command = list_of_tokens[0]
23
- list_of_tokens.pop(0)
24
-
25
- flags: FlagsGroup = FlagsGroup()
26
- current_flag_name = None
27
- current_flag_value = None
28
- for _ in list_of_tokens:
29
- if _.startswith('-'):
30
- flag_prefix_last_symbol_index = _.rfind('-')
31
- if current_flag_name or len(_) < 2 or len(_[:flag_prefix_last_symbol_index]) > 3:
32
- raise UnprocessedInputFlagException()
33
- else:
34
- current_flag_name = _
35
- else:
36
- if not current_flag_name:
37
- raise UnprocessedInputFlagException()
38
- else:
39
- current_flag_value = _
40
- if current_flag_name and current_flag_value:
41
- flag_prefix_last_symbol_index = current_flag_name.rfind('-')
42
- flag_prefix = current_flag_name[:flag_prefix_last_symbol_index]
43
- flag_name = current_flag_name[flag_prefix_last_symbol_index:]
44
-
45
- input_flag = InputFlag(flag_name=flag_name,
46
- flag_prefix=flag_prefix)
47
- input_flag.set_value(current_flag_value)
48
-
49
- all_flags = [x.get_string_entity() for x in flags.get_flags()]
50
- if input_flag.get_string_entity() not in all_flags:
51
- flags.add_flag(input_flag)
52
- else:
53
- raise RepeatedInputFlagsException(input_flag)
54
-
55
- current_flag_name = None
56
- current_flag_value = None
57
- if any([current_flag_name, current_flag_value]):
58
- raise UnprocessedInputFlagException()
59
- if len(flags.get_flags()) == 0:
60
- return InputCommand(command=command)
61
- else:
62
- input_command = InputCommand(command=command)
63
- input_command.set_input_flags(flags)
64
- return input_command
65
-
66
-
@@ -1,37 +0,0 @@
1
- from ..params.flag.input_flag.entity import InputFlag
2
-
3
-
4
- class UnprocessedInputFlagException(Exception):
5
- def __str__(self):
6
- return "Unprocessed Input Flags"
7
-
8
-
9
- class RepeatedInputFlagsException(Exception):
10
- def __init__(self, flag: InputFlag):
11
- self.flag = flag
12
- def __str__(self):
13
- return ("Repeated Input Flags\n"
14
- f"Duplicate flag was detected in the input: '{self.flag.get_string_entity()}'")
15
-
16
-
17
- class InvalidInputFlagsHandlerHasBeenAlreadyCreatedException(Exception):
18
- def __str__(self):
19
- return "Invalid Input Flags Handler has already been created"
20
-
21
-
22
- class RepeatedInputFlagsHandlerHasBeenAlreadyCreatedException(Exception):
23
- def __str__(self):
24
- return "Repeated Input Flags Handler has already been created"
25
-
26
-
27
- class UnknownCommandHandlerHasBeenAlreadyCreatedException(Exception):
28
- def __str__(self):
29
- return "Unknown Command Handler has already been created"
30
-
31
-
32
- class IncorrectNumberOfHandlerArgsException(Exception):
33
- def __str__(self):
34
- return "Incorrect Input Flags Handler has incorrect number of arguments"
35
-
36
-
37
-
File without changes
@@ -1,11 +0,0 @@
1
- from ...flag.entity import Flag
2
-
3
-
4
- class InputFlag(Flag):
5
- def set_value(self, value: str):
6
- self._value = value
7
-
8
- def get_value(self) -> str:
9
- return self._value
10
-
11
-
@@ -1,24 +0,0 @@
1
- argenta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- argenta/app/__init__.py,sha256=yOt8-2lholVRUtLPwAXuemh115q1unP1PKLBR_7cd4E,152
3
- argenta/app/entity.py,sha256=xpSniSZ6kE8Q68IeTkVedoeHAuoX6MOv7XPqrF0E6zA,12081
4
- argenta/app/exceptions.py,sha256=7_p_5NS_paLAU3xGAWufpfkdTxRx07T2zWYzGKdlCMs,1086
5
- argenta/command/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- argenta/command/entity.py,sha256=9FkU_NbI1WsXrnKA1Ba86xwYoRwLLdk81yI9dj7RsF8,2451
7
- argenta/command/exceptions.py,sha256=qTt3G0XaWW5BBQyxNkVWFY0SMGn92VuxvSRs0G37lHI,366
8
- argenta/command/input_comand/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- argenta/command/input_comand/entity.py,sha256=LJCp_qE9Oea03rMH98plQnHr6VcJDhrFTda6g8iS6YA,2593
10
- argenta/command/input_comand/exceptions.py,sha256=FD0pHstIi8oPZRjJDZzRmjl51J1bHcE12iZ9U-n3Qg0,1143
11
- argenta/command/params/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- argenta/command/params/flag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- argenta/command/params/flag/entity.py,sha256=gUax6hkuSuarH8yQwFC4QsGql8n1POi19Ww4yEh2c2k,1446
14
- argenta/command/params/flag/flags_group/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- argenta/command/params/flag/flags_group/entity.py,sha256=MZ2tsSgVIP5sTvheMuHX6DydfAu7xtnjdWHAAA9Qq9g,708
16
- argenta/command/params/flag/input_flag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- argenta/command/params/flag/input_flag/entity.py,sha256=KHoZRE7pRc30LyS6yF_7G7IrA8DrH-gS-Hg_qNstkzU,195
18
- argenta/router/__init__.py,sha256=ZedowNgGR9OphLSg9fXp6-uvjyf23rbq-rEtuHScAIM,87
19
- argenta/router/entity.py,sha256=ZiqA_xTDhDIvHCjlxrqWMWm_HgAAMrpJIgRuN5Oihec,6267
20
- argenta/router/exceptions.py,sha256=9PGOGiHoPZNvpwPwSIKyAVawj2r9sQUg4bXFmfiWVvI,1048
21
- argenta-0.3.2.dist-info/LICENSE,sha256=zmqoGh2n5rReBv4s8wPxF_gZEZDgauJYSPMuPczgOiU,1082
22
- argenta-0.3.2.dist-info/METADATA,sha256=dyVqc_A0p-2HSfElaXCtEVxYGyejhltSXafXRPMXcNE,12638
23
- argenta-0.3.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
24
- argenta-0.3.2.dist-info/RECORD,,