argenta 0.1.2__tar.gz → 0.1.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: argenta
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: python library for creating cli apps
5
5
  License: MIT
6
6
  Author: kolo
@@ -13,56 +13,56 @@ class App:
13
13
  prompt: str = 'Enter a command',
14
14
  exit_command: str = 'q',
15
15
  ignore_exit_command_register: bool = True,
16
- initial_greeting: str = 'Hello',
17
- goodbye_message: str = 'GoodBye',
18
- line_separate: str = '\n',
19
- command_group_description_separate: str = '\n',
16
+ initial_greeting: str = '\nHello, I am Argenta\n',
17
+ farewell_message: str = 'GoodBye',
18
+ line_separate: str = '',
19
+ command_group_description_separate: str = '',
20
20
  print_func: Callable[[str], None] = print) -> None:
21
21
  self.prompt = prompt
22
22
  self.print_func = print_func
23
23
  self.exit_command = exit_command
24
24
  self.ignore_exit_command_register = ignore_exit_command_register
25
- self.goodbye_message = goodbye_message
25
+ self.farewell_message = farewell_message
26
26
  self.initial_greeting = initial_greeting
27
27
  self.line_separate = line_separate
28
28
  self.command_group_description_separate = command_group_description_separate
29
29
 
30
- self.routers: list[Router] = []
31
- self.registered_commands: list[dict[str, str | list[dict[str, Callable[[], None] | str]] | Router]] = []
32
- self.main_app_router: Router | None = None
33
- self._description_message_pattern = '[{command}] *=*=* {description}'
30
+ self._routers: list[Router] = []
31
+ self._registered_commands: list[dict[str, str | list[dict[str, Callable[[], None] | str]] | Router]] = []
32
+ self._main_app_router: Router | None = None
33
+ self._description_message_pattern: str = '[{command}] *=*=* {description}'
34
34
 
35
35
 
36
36
  def start_polling(self) -> None:
37
37
  self.print_func(self.initial_greeting)
38
- self.validate_main_router()
38
+ self._validate_main_router()
39
39
 
40
40
  while True:
41
- self.print_command_group_description()
41
+ self._print_command_group_description()
42
42
  self.print_func(self.prompt)
43
43
 
44
44
  command: str = input()
45
45
 
46
- self.checking_command_for_exit_command(command)
46
+ self._checking_command_for_exit_command(command)
47
47
  self.print_func(self.line_separate)
48
48
 
49
- is_unknown_command: bool = self.check_is_command_unknown(command)
49
+ is_unknown_command: bool = self._check_is_command_unknown(command)
50
50
 
51
51
  if is_unknown_command:
52
52
  continue
53
53
 
54
- for router in self.routers:
54
+ for router in self._routers:
55
55
  router.input_command_handler(command)
56
56
  self.print_func(self.line_separate)
57
57
  self.print_func(self.command_group_description_separate)
58
58
 
59
59
 
60
60
  def set_initial_greeting(self, greeting: str) -> None:
61
- self.initial_greeting = greeting
61
+ self.initial_greeting: str = greeting
62
62
 
63
63
 
64
- def set_goodbye_message(self, message: str) -> None:
65
- self.goodbye_message = message
64
+ def set_farewell_message(self, message: str) -> None:
65
+ self.farewell_message: str = message
66
66
 
67
67
 
68
68
  def set_description_message_pattern(self, pattern: str) -> None:
@@ -71,34 +71,34 @@ class App:
71
71
  description='description')
72
72
  except KeyError:
73
73
  raise InvalidDescriptionMessagePatternException(pattern)
74
- self._description_message_pattern = pattern
74
+ self._description_message_pattern: str = pattern
75
75
 
76
76
 
77
- def validate_main_router(self):
78
- if not self.main_app_router:
77
+ def _validate_main_router(self):
78
+ if not self._main_app_router:
79
79
  raise MissingMainRouterException()
80
80
 
81
- if not self.main_app_router.unknown_command_func:
81
+ if not self._main_app_router.unknown_command_func:
82
82
  raise MissingHandlersForUnknownCommandsOnMainRouterException()
83
83
 
84
- for router in self.routers:
85
- if router.unknown_command_func and self.main_app_router is not router:
84
+ for router in self._routers:
85
+ if router.unknown_command_func and self._main_app_router is not router:
86
86
  raise HandlerForUnknownCommandsCanOnlyBeDeclaredForMainRouterException()
87
87
 
88
88
 
89
- def checking_command_for_exit_command(self, command: str):
89
+ def _checking_command_for_exit_command(self, command: str):
90
90
  if command.lower() == self.exit_command.lower():
91
91
  if self.ignore_exit_command_register:
92
- self.print_func(self.goodbye_message)
92
+ self.print_func(self.farewell_message)
93
93
  exit(0)
94
94
  else:
95
95
  if command == self.exit_command:
96
- self.print_func(self.goodbye_message)
96
+ self.print_func(self.farewell_message)
97
97
  exit(0)
98
98
 
99
99
 
100
- def check_is_command_unknown(self, command: str):
101
- registered_commands = self.registered_commands
100
+ def _check_is_command_unknown(self, command: str):
101
+ registered_commands: list[dict[str, str | list[dict[str, Callable[[], None] | str]] | Router]] = self._registered_commands
102
102
  for router in registered_commands:
103
103
  for command_entity in router['commands']:
104
104
  if command_entity['command'].lower() == command.lower():
@@ -107,14 +107,14 @@ class App:
107
107
  else:
108
108
  if command_entity['command'] == command:
109
109
  return False
110
- self.main_app_router.unknown_command_handler(command)
110
+ self._main_app_router.unknown_command_handler(command)
111
111
  self.print_func(self.line_separate)
112
112
  self.print_func(self.command_group_description_separate)
113
113
  return True
114
114
 
115
115
 
116
- def print_command_group_description(self):
117
- for router in self.registered_commands:
116
+ def _print_command_group_description(self):
117
+ for router in self._registered_commands:
118
118
  self.print_func(router['name'])
119
119
  for command_entity in router['commands']:
120
120
  self.print_func(self._description_message_pattern.format(
@@ -130,16 +130,16 @@ class App:
130
130
  raise InvalidRouterInstanceException()
131
131
 
132
132
  if is_main:
133
- if not self.main_app_router:
134
- self.main_app_router = router
133
+ if not self._main_app_router:
134
+ self._main_app_router = router
135
135
  router.set_router_as_main()
136
136
  else:
137
137
  raise OnlyOneMainRouterIsAllowedException(router)
138
138
 
139
- self.routers.append(router)
139
+ self._routers.append(router)
140
140
 
141
141
  registered_commands: list[dict[str, Callable[[], None] | str]] = router.get_registered_commands()
142
- self.registered_commands.append({'name': router.get_name(),
142
+ self._registered_commands.append({'name': router.get_name(),
143
143
  'router': router,
144
144
  'commands': registered_commands})
145
145
 
@@ -9,10 +9,10 @@ class Router:
9
9
  name: str,
10
10
  ignore_command_register: bool = False):
11
11
 
12
- self.ignore_command_register: bool = ignore_command_register
13
- self._name = name
12
+ self.ignore_command_register = ignore_command_register
13
+ self.name = name
14
14
 
15
- self.processed_commands: list[dict[str, Callable[[], None] | str]] = []
15
+ self._processed_commands: list[dict[str, Callable[[], None] | str]] = []
16
16
  self.unknown_command_func: Callable[[str], None] | None = None
17
17
  self._is_main_router: bool = False
18
18
 
@@ -24,7 +24,7 @@ class Router:
24
24
  raise InvalidDescriptionInstanceException()
25
25
  else:
26
26
  def command_decorator(func):
27
- self.processed_commands.append({'func': func,
27
+ self._processed_commands.append({'func': func,
28
28
  'command': command,
29
29
  'description': description})
30
30
  def wrapper(*args, **kwargs):
@@ -37,7 +37,7 @@ class Router:
37
37
  if self.unknown_command_func is not None:
38
38
  raise UnknownCommandHandlerHasAlreadyBeenCreatedException()
39
39
 
40
- self.unknown_command_func = func
40
+ self.unknown_command_func: Callable = func
41
41
 
42
42
  def wrapper(*args, **kwargs):
43
43
  return func(*args, **kwargs)
@@ -45,7 +45,7 @@ class Router:
45
45
 
46
46
 
47
47
  def input_command_handler(self, input_command):
48
- for command_entity in self.processed_commands:
48
+ for command_entity in self._processed_commands:
49
49
  if input_command.lower() == command_entity['command'].lower():
50
50
  if self.ignore_command_register:
51
51
  return command_entity['func']()
@@ -53,6 +53,7 @@ class Router:
53
53
  if input_command == command_entity['command']:
54
54
  return command_entity['func']()
55
55
 
56
+
56
57
  def unknown_command_handler(self, unknown_command):
57
58
  self.unknown_command_func(unknown_command)
58
59
 
@@ -62,9 +63,9 @@ class Router:
62
63
 
63
64
 
64
65
  def get_registered_commands(self) -> list[dict[str, Callable[[], None] | str]]:
65
- return self.processed_commands
66
+ return self._processed_commands
66
67
 
67
68
 
68
69
  def get_name(self) -> str:
69
- return self._name
70
+ return self.name
70
71
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "argenta"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  description = "python library for creating cli apps"
5
5
  authors = [
6
6
  {name = "kolo",email = "kolo.is.main@gmail.com"}
@@ -15,3 +15,14 @@ dependencies = [
15
15
  [build-system]
16
16
  requires = ["poetry-core>=2.0.0,<3.0.0"]
17
17
  build-backend = "poetry.core.masonry.api"
18
+
19
+ [tool.poetry.group.dev.dependencies]
20
+ art = "^6.4"
21
+ rich = "^13.9.4"
22
+ numpy = "^2.2.2"
23
+ word2number = "^1.1"
24
+ numexpr = "^2.10.2"
25
+ requests = "^2.32.3"
26
+ tqdm = "^4.67.1"
27
+ setuptools = "^75.8.0"
28
+
File without changes
File without changes
File without changes
File without changes