anb-console 1.0__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.
Files changed (51) hide show
  1. anb_console-1.0/LICENSE +8 -0
  2. anb_console-1.0/PKG-INFO +109 -0
  3. anb_console-1.0/README.md +75 -0
  4. anb_console-1.0/anb_console/__init__.py +16 -0
  5. anb_console-1.0/anb_console/abstracts/__init__.py +4 -0
  6. anb_console-1.0/anb_console/abstracts/console_component.py +139 -0
  7. anb_console-1.0/anb_console/abstracts/console_reader.py +544 -0
  8. anb_console-1.0/anb_console/classes/__init__.py +6 -0
  9. anb_console-1.0/anb_console/classes/console.py +495 -0
  10. anb_console-1.0/anb_console/classes/console_line.py +123 -0
  11. anb_console-1.0/anb_console/classes/console_line_segment.py +67 -0
  12. anb_console-1.0/anb_console/classes/console_text_markup.py +93 -0
  13. anb_console-1.0/anb_console/components/__init__.py +5 -0
  14. anb_console-1.0/anb_console/components/console_progressbar.py +551 -0
  15. anb_console-1.0/anb_console/components/console_separator.py +141 -0
  16. anb_console-1.0/anb_console/components/console_textbox.py +75 -0
  17. anb_console-1.0/anb_console/enums/__init__.py +6 -0
  18. anb_console-1.0/anb_console/enums/console_line_style.py +81 -0
  19. anb_console-1.0/anb_console/enums/console_progressbar_style.py +13 -0
  20. anb_console-1.0/anb_console/enums/console_reader_option.py +19 -0
  21. anb_console-1.0/anb_console/enums/console_readkey_result.py +13 -0
  22. anb_console-1.0/anb_console/extensions/__init__.py +3 -0
  23. anb_console-1.0/anb_console/extensions/console_text_area.py +173 -0
  24. anb_console-1.0/anb_console/readers/__init__.py +7 -0
  25. anb_console-1.0/anb_console/readers/console_number_reader.py +242 -0
  26. anb_console-1.0/anb_console/readers/console_password_reader.py +78 -0
  27. anb_console-1.0/anb_console/readers/console_text_reader.py +57 -0
  28. anb_console-1.0/anb_console/readers/console_variant_reader.py +423 -0
  29. anb_console-1.0/anb_console/readers/console_yes_no_reader.py +67 -0
  30. anb_console-1.0/anb_console.egg-info/PKG-INFO +109 -0
  31. anb_console-1.0/anb_console.egg-info/SOURCES.txt +49 -0
  32. anb_console-1.0/anb_console.egg-info/dependency_links.txt +1 -0
  33. anb_console-1.0/anb_console.egg-info/not-zip-safe +1 -0
  34. anb_console-1.0/anb_console.egg-info/requires.txt +2 -0
  35. anb_console-1.0/anb_console.egg-info/top_level.txt +2 -0
  36. anb_console-1.0/anb_console_test/__init__.py +1 -0
  37. anb_console-1.0/anb_console_test/console_components_test.py +47 -0
  38. anb_console-1.0/anb_console_test/console_readers_test.py +51 -0
  39. anb_console-1.0/anb_console_test/console_test.py +76 -0
  40. anb_console-1.0/anb_console_test/console_test_general.py +59 -0
  41. anb_console-1.0/anb_console_test/console_test_number_reader.py +97 -0
  42. anb_console-1.0/anb_console_test/console_test_password_reader.py +51 -0
  43. anb_console-1.0/anb_console_test/console_test_progressbar.py +122 -0
  44. anb_console-1.0/anb_console_test/console_test_separator.py +50 -0
  45. anb_console-1.0/anb_console_test/console_test_text_area.py +34 -0
  46. anb_console-1.0/anb_console_test/console_test_text_reader.py +56 -0
  47. anb_console-1.0/anb_console_test/console_test_textbox.py +56 -0
  48. anb_console-1.0/anb_console_test/console_test_variant_reader.py +58 -0
  49. anb_console-1.0/anb_console_test/console_test_yes_no_reader.py +56 -0
  50. anb_console-1.0/setup.cfg +4 -0
  51. anb_console-1.0/setup.py +75 -0
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright © 2026 Alexander Babaev and Team
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: anb_console
3
+ Version: 1.0
4
+ Summary: Простой менеджер консоли
5
+ Home-page: https://gitflic.ru/project/babaev-an/anb_console
6
+ Author: Александр Бабаев
7
+ Author-email: contact_with_us@babaev-an.ru
8
+ Project-URL: Documentation, https://gitflic.ru/project/babaev-an/anb_console/blob?file=README.md&branch=master
9
+ Project-URL: Source, https://gitflic.ru/project/babaev-an/anb_console
10
+ Project-URL: Tracker, https://gitflic.ru/project/babaev-an/anb_console/issue
11
+ Keywords: python components development utils
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.15.2
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: setuptools>=84.2.1
21
+ Requires-Dist: colorama>=0.4.6
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license-file
30
+ Dynamic: project-url
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ from _pyrepl import consolefrom anb_console import ConsoleProgressBarStyle
36
+
37
+ # anb_console
38
+
39
+ ## Описание проекта
40
+
41
+ `anb_console` — это фреймворк на Python для создания командных интерфейсов (CLI) с богатой текстовой разметкой, обработкой ввода и настраиваемыми элементами пользовательского интерфейса. Он предоставляет классы для отображения текста, обработки ввода и повторно используемых элементов консоли.
42
+
43
+ ## Основные компоненты
44
+
45
+ ### Основные классы
46
+
47
+ - **Console**: Основной класс для управления выводом в консоль и обработкой ввода.
48
+ - **ConsoleLine**: Представляет строку текста со стилем и позиционированием.
49
+ - **ConsoleLineSegment**: Отрезки текста внутри строки (например, для окрашенного текста).
50
+ - **ConsoleTextMarkup**: Утилиты для форматирования и стилизации текста.
51
+
52
+ ### Читатели ввода
53
+
54
+ - **ConsoleYesNoReader**: Обработка запросов на подтверждение (да/нет).
55
+ - **ConsolePasswordReader**: Безопасный ввод пароля.
56
+ - **ConsoleNumberReader**: Валидация числового ввода.
57
+ - **ConsoleVariantReader**: Многоопционный выбор.
58
+
59
+ ### Элементы пользовательского интерфейса
60
+
61
+ - **ConsoleTextBox**: Поле ввода текста.
62
+ - **ConsoleProgressBar**: Индикатор прогресса.
63
+ - **ConsoleSeparator**: Визуальные разделительные линии.
64
+ - **ConsoleTextArea**: Многострочная область текста.
65
+
66
+ ### Энамы и абстракции
67
+
68
+ - **ConsoleReaderOption**: Опции для обработки ввода.
69
+ - **ConsoleProgressBarStyle**: Стили прогресс-баров.
70
+ - **ConsoleLineStyle**: Опции стилизации текста.
71
+ - **ConsoleComponent (Абстрактный)**: Базовый класс для элементов UI.
72
+ - **ConsoleReader (Абстрактный)**: Базовый класс для обработчиков ввода.
73
+
74
+ ## Использование
75
+
76
+ 1. Импортируйте основные классы для работы с текстом:
77
+
78
+ ```python
79
+ from anb_console.classes import Console, ConsoleLine
80
+ ```
81
+
82
+ 2. Используйте читатели ввода для интерактивных запросов:
83
+
84
+ ```python
85
+ from anb_console import Console, ConsoleYesNoReader
86
+
87
+ console = Console()
88
+ reader = ConsoleYesNoReader(console)
89
+ response = reader.read()
90
+ ```
91
+
92
+ 3. Создайте элементы пользовательского интерфейса:
93
+
94
+ ```python
95
+ from anb_console import Console, ConsoleProgressBar, ConsoleProgressBarStyle
96
+
97
+ console = Console()
98
+ progress = ConsoleProgressBar(console.add_line(), 100)
99
+ progress.style = ConsoleProgressBarStyle.MARQUEE
100
+ progress.start()
101
+ ```
102
+
103
+ ## Разработка
104
+
105
+ - Классы организованы в `anb_console/classes`, `anb_console/readers` и `anb_console/components`
106
+ - Энамы и абстрактные классы находятся в `anb_console/enums` и `anb_console/abstracts`
107
+
108
+ ## Ошибки
109
+ О найденных ошибках вы можете сообщать в [GitFlic проблемах](https://gitflic.ru/project/babaev-an/anb_console/issue).
@@ -0,0 +1,75 @@
1
+ from _pyrepl import consolefrom anb_console import ConsoleProgressBarStyle
2
+
3
+ # anb_console
4
+
5
+ ## Описание проекта
6
+
7
+ `anb_console` — это фреймворк на Python для создания командных интерфейсов (CLI) с богатой текстовой разметкой, обработкой ввода и настраиваемыми элементами пользовательского интерфейса. Он предоставляет классы для отображения текста, обработки ввода и повторно используемых элементов консоли.
8
+
9
+ ## Основные компоненты
10
+
11
+ ### Основные классы
12
+
13
+ - **Console**: Основной класс для управления выводом в консоль и обработкой ввода.
14
+ - **ConsoleLine**: Представляет строку текста со стилем и позиционированием.
15
+ - **ConsoleLineSegment**: Отрезки текста внутри строки (например, для окрашенного текста).
16
+ - **ConsoleTextMarkup**: Утилиты для форматирования и стилизации текста.
17
+
18
+ ### Читатели ввода
19
+
20
+ - **ConsoleYesNoReader**: Обработка запросов на подтверждение (да/нет).
21
+ - **ConsolePasswordReader**: Безопасный ввод пароля.
22
+ - **ConsoleNumberReader**: Валидация числового ввода.
23
+ - **ConsoleVariantReader**: Многоопционный выбор.
24
+
25
+ ### Элементы пользовательского интерфейса
26
+
27
+ - **ConsoleTextBox**: Поле ввода текста.
28
+ - **ConsoleProgressBar**: Индикатор прогресса.
29
+ - **ConsoleSeparator**: Визуальные разделительные линии.
30
+ - **ConsoleTextArea**: Многострочная область текста.
31
+
32
+ ### Энамы и абстракции
33
+
34
+ - **ConsoleReaderOption**: Опции для обработки ввода.
35
+ - **ConsoleProgressBarStyle**: Стили прогресс-баров.
36
+ - **ConsoleLineStyle**: Опции стилизации текста.
37
+ - **ConsoleComponent (Абстрактный)**: Базовый класс для элементов UI.
38
+ - **ConsoleReader (Абстрактный)**: Базовый класс для обработчиков ввода.
39
+
40
+ ## Использование
41
+
42
+ 1. Импортируйте основные классы для работы с текстом:
43
+
44
+ ```python
45
+ from anb_console.classes import Console, ConsoleLine
46
+ ```
47
+
48
+ 2. Используйте читатели ввода для интерактивных запросов:
49
+
50
+ ```python
51
+ from anb_console import Console, ConsoleYesNoReader
52
+
53
+ console = Console()
54
+ reader = ConsoleYesNoReader(console)
55
+ response = reader.read()
56
+ ```
57
+
58
+ 3. Создайте элементы пользовательского интерфейса:
59
+
60
+ ```python
61
+ from anb_console import Console, ConsoleProgressBar, ConsoleProgressBarStyle
62
+
63
+ console = Console()
64
+ progress = ConsoleProgressBar(console.add_line(), 100)
65
+ progress.style = ConsoleProgressBarStyle.MARQUEE
66
+ progress.start()
67
+ ```
68
+
69
+ ## Разработка
70
+
71
+ - Классы организованы в `anb_console/classes`, `anb_console/readers` и `anb_console/components`
72
+ - Энамы и абстрактные классы находятся в `anb_console/enums` и `anb_console/abstracts`
73
+
74
+ ## Ошибки
75
+ О найденных ошибках вы можете сообщать в [GitFlic проблемах](https://gitflic.ru/project/babaev-an/anb_console/issue).
@@ -0,0 +1,16 @@
1
+ # anb_console/__init__.py
2
+
3
+ # abstracts
4
+ from anb_console.abstracts import ConsoleComponent, ConsoleReader
5
+ # classes
6
+ from anb_console.classes import Console, ConsoleLine, ConsoleLineSegment, ConsoleTextMarkup
7
+ # components
8
+ from anb_console.components import ConsoleTextBox, ConsoleProgressBar, ConsoleSeparator
9
+ # enums
10
+ from anb_console.enums import ConsoleLineStyle, ConsoleProgressBarStyle, ConsoleReadKeyResult, ConsoleReaderOption
11
+ # extensions
12
+ from anb_console.extensions import ConsoleTextArea
13
+ # readers
14
+ from anb_console.readers import (
15
+ ConsoleTextReader, ConsoleNumberReader, ConsolePasswordReader, ConsoleYesNoReader, ConsoleVariantReader
16
+ )
@@ -0,0 +1,4 @@
1
+ # anb_console/abstracts/__init__.py
2
+
3
+ from anb_console.abstracts.console_component import ConsoleComponent
4
+ from anb_console.abstracts.console_reader import ConsoleReader
@@ -0,0 +1,139 @@
1
+ # anb_console/abstracts/console_component.py
2
+
3
+ from abc import ABC, abstractmethod
4
+
5
+ from anb_console.classes import ConsoleLine
6
+
7
+
8
+ class ConsoleComponent(ABC):
9
+ """
10
+ Базовый класс для компонентов консоли.
11
+ """
12
+
13
+ def __init__(self, line: ConsoleLine, auto_flush: bool = False) -> None:
14
+ """
15
+ Создание компонента консоли.
16
+
17
+ :param line: Линия консоли.
18
+ :param auto_flush: Автоматическая отрисовка. По умолчанию, False.
19
+
20
+ :return: None
21
+ """
22
+ # Сохраняем ссылку на линию консоли
23
+ self._line: ConsoleLine = line
24
+
25
+ # Автоматическая отрисовка выключена по умолчанию:
26
+ # компонент меняется пачками, рисовать должен владелец цикла
27
+ self._auto_flush: bool = auto_flush
28
+
29
+ # Вызываем метод update(), так как компонент рождается уже нарисованным
30
+ self.update()
31
+
32
+ @property
33
+ def auto_flush(self) -> bool:
34
+ """
35
+ Получает, включена ли автоматическая отрисовка.
36
+
37
+ :return: True, если автоматическая отрисовка включена, иначе False.
38
+ """
39
+ return self._auto_flush
40
+
41
+ @auto_flush.setter
42
+ def auto_flush(self, value: bool) -> None:
43
+ """
44
+ Устанавливает, включена ли автоматическая отрисовка.
45
+
46
+ :param value: True, если автоматическая отрисовка включена, иначе False.
47
+
48
+ :return: None
49
+ """
50
+ self._auto_flush = value
51
+
52
+ @auto_flush.deleter
53
+ def auto_flush(self) -> None:
54
+ """
55
+ Удаляет автоматическую отрисовку.
56
+
57
+ :return: None
58
+ """
59
+ self._auto_flush = False
60
+
61
+ @property
62
+ def line(self) -> ConsoleLine:
63
+ """
64
+ Получает текущую линию вывода компонента.
65
+
66
+ :return: Текущая линия вывода компонента.
67
+ """
68
+ return self._line
69
+
70
+ @line.setter
71
+ def line(self, new_line: ConsoleLine) -> None:
72
+ """
73
+ Устанавливает новую линию вывода компонента:
74
+ предыдущая линия очищается, компонент перерисовывается на новой.
75
+
76
+ :param new_line: Новая линия вывода в консоли.
77
+
78
+ :return: None
79
+ """
80
+ # Если линию не меняли
81
+ if new_line is self._line:
82
+ # - ничего не делаем
83
+ return
84
+
85
+ # Очищаем предыдущую линию
86
+ self._line.clear()
87
+
88
+ # Сохраняем новую линию
89
+ self._line = new_line
90
+
91
+ # Перерисовываем компонент на новом месте
92
+ self.render()
93
+
94
+ @abstractmethod
95
+ def render(self) -> None:
96
+ """
97
+ Перерисовать своё состояние в линию консоли.
98
+
99
+ :return: None
100
+ """
101
+ pass
102
+
103
+ def update(self) -> None:
104
+ """
105
+ Обновляет компонент: перерисовывает его состояние в линию
106
+ и помечает линию для отрисовки (или рисует немедленно,
107
+ если включена auto_flush).
108
+
109
+ :return: None
110
+ """
111
+ # Перерисовываем состояние в сегменты линии
112
+ self.render()
113
+
114
+ # Отмечаем линию (или рисуем немедленно)
115
+ self._line.update(self._auto_flush)
116
+
117
+ def clear(self) -> None:
118
+ """
119
+ Очищает компонент: сбрасывает его состояние и линию.
120
+
121
+ :return: None
122
+ """
123
+ # Хук: подклассы очищают своё внутреннее состояние
124
+ self._clear_state()
125
+
126
+ # Очищаем линию
127
+ self.line.clear()
128
+
129
+ # Перерисовываем компонент
130
+ self.update()
131
+
132
+ def _clear_state(self) -> None:
133
+ """
134
+ Сбрасывает внутреннее состояние компонента к значению по умолчанию.
135
+ Подклассы с состоянием переопределяют этот метод.
136
+
137
+ :return: None
138
+ """
139
+ pass