argenta 1.0.6__py3-none-any.whl → 1.1.1__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/__init__.py CHANGED
@@ -0,0 +1,10 @@
1
+ __all__ = [
2
+ 'App',
3
+ 'Orchestrator',
4
+ 'Router',
5
+ ]
6
+
7
+
8
+ from argenta.app import App
9
+ from argenta.orchestrator import Orchestrator
10
+ from argenta.router import Router
argenta/app/__init__.py CHANGED
@@ -1,3 +1,12 @@
1
- __all__ = ["App"]
1
+ __all__ = [
2
+ "App",
3
+ "PredefinedMessages",
4
+ "DynamicDividingLine",
5
+ "StaticDividingLine",
6
+ "AutoCompleter"
7
+ ]
2
8
 
3
9
  from argenta.app.models import App
10
+ from argenta.app.defaults import PredefinedMessages
11
+ from argenta.app.dividing_line.models import DynamicDividingLine, StaticDividingLine
12
+ from argenta.app.autocompleter.entity import AutoCompleter
@@ -13,10 +13,10 @@ class AutoCompleter:
13
13
  :param autocomplete_button: the button for auto-completion
14
14
  :return: None
15
15
  """
16
- self.history_filename = history_filename
17
- self.autocomplete_button = autocomplete_button
16
+ self.history_filename: str | None = history_filename
17
+ self.autocomplete_button: str = autocomplete_button
18
18
 
19
- def _complete(self, text, state) -> str | None:
19
+ def _complete(self, text: str, state: int) -> str | None:
20
20
  """
21
21
  Private. Auto-completion function
22
22
  :param text: part of the command being entered
@@ -24,7 +24,7 @@ class AutoCompleter:
24
24
  :return: the desired candidate as str or None
25
25
  """
26
26
  matches: list[str] = sorted(
27
- cmd for cmd in self.get_history_items() if cmd.startswith(text)
27
+ cmd for cmd in _get_history_items() if cmd.startswith(text)
28
28
  )
29
29
  if len(matches) > 1:
30
30
  common_prefix = matches[0]
@@ -38,7 +38,7 @@ class AutoCompleter:
38
38
  i += 1
39
39
  common_prefix = common_prefix[:i]
40
40
  if state == 0:
41
- readline.insert_text(common_prefix[len(text) :])
41
+ readline.insert_text(common_prefix[len(text) :])
42
42
  readline.redisplay()
43
43
  return None
44
44
  elif len(matches) == 1:
@@ -54,10 +54,10 @@ class AutoCompleter:
54
54
  """
55
55
  if self.history_filename:
56
56
  if os.path.exists(self.history_filename):
57
- readline.read_history_file(self.history_filename)
57
+ readline.read_history_file(self.history_filename)
58
58
  else:
59
59
  for line in all_commands:
60
- readline.add_history(line)
60
+ readline.add_history(line)
61
61
 
62
62
  readline.set_completer(self._complete)
63
63
  readline.set_completer_delims(readline.get_completer_delims().replace(" ", ""))
@@ -69,7 +69,7 @@ class AutoCompleter:
69
69
  :return: None
70
70
  """
71
71
  if self.history_filename:
72
- readline.write_history_file(self.history_filename)
72
+ readline.write_history_file(self.history_filename)
73
73
  with open(self.history_filename, "r") as history_file:
74
74
  raw_history = history_file.read()
75
75
  pretty_history: list[str] = []
@@ -77,15 +77,14 @@ class AutoCompleter:
77
77
  if line.split()[0] in all_commands:
78
78
  pretty_history.append(line)
79
79
  with open(self.history_filename, "w") as history_file:
80
- history_file.write("\n".join(pretty_history))
80
+ _ = history_file.write("\n".join(pretty_history))
81
81
 
82
- @staticmethod
83
- def get_history_items() -> list[str] | list[Never]:
84
- """
85
- Private. Returns a list of all commands entered by the user
86
- :return: all commands entered by the user as list[str] | list[Never]
87
- """
88
- return [
89
- readline.get_history_item(i)
90
- for i in range(1, readline.get_current_history_length() + 1)
91
- ]
82
+ def _get_history_items() -> list[str] | list[Never]:
83
+ """
84
+ Private. Returns a list of all commands entered by the user
85
+ :return: all commands entered by the user as list[str] | list[Never]
86
+ """
87
+ return [
88
+ readline.get_history_item(i)
89
+ for i in range(1, readline.get_current_history_length() + 1)
90
+ ]
@@ -8,7 +8,7 @@ class BaseDividingLine(ABC):
8
8
  :param unit_part: the single part of the dividing line
9
9
  :return: None
10
10
  """
11
- self._unit_part = unit_part
11
+ self._unit_part: str = unit_part
12
12
 
13
13
  def get_unit_part(self) -> str:
14
14
  """
@@ -22,7 +22,7 @@ class BaseDividingLine(ABC):
22
22
 
23
23
 
24
24
  class StaticDividingLine(BaseDividingLine):
25
- def __init__(self, unit_part: str = "-", length: int = 25) -> None:
25
+ def __init__(self, unit_part: str = "-", *, length: int = 25) -> None:
26
26
  """
27
27
  Public. The static dividing line
28
28
  :param unit_part: the single part of the dividing line
@@ -30,9 +30,9 @@ class StaticDividingLine(BaseDividingLine):
30
30
  :return: None
31
31
  """
32
32
  super().__init__(unit_part)
33
- self.length = length
33
+ self.length: int = length
34
34
 
35
- def get_full_static_line(self, is_override: bool) -> str:
35
+ def get_full_static_line(self, *, is_override: bool) -> str:
36
36
  """
37
37
  Private. Returns the full line of the dividing line
38
38
  :param is_override: has the default text layout been redefined
@@ -53,7 +53,7 @@ class DynamicDividingLine(BaseDividingLine):
53
53
  """
54
54
  super().__init__(unit_part)
55
55
 
56
- def get_full_dynamic_line(self, length: int, is_override: bool) -> str:
56
+ def get_full_dynamic_line(self, *, length: int, is_override: bool) -> str:
57
57
  """
58
58
  Private. Returns the full line of the dividing line
59
59
  :param length: the length of the dividing line