plotext-plus 1.0.8__py3-none-any.whl → 1.0.10__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.
- plotext_plus/__init__.py +20 -15
- plotext_plus/__main__.py +1 -0
- plotext_plus/_api.py +632 -371
- plotext_plus/_build.py +765 -149
- plotext_plus/_core.py +609 -164
- plotext_plus/_date.py +50 -32
- plotext_plus/_default.py +35 -28
- plotext_plus/_dict.py +807 -103
- plotext_plus/_doc.py +867 -296
- plotext_plus/_doc_utils.py +279 -245
- plotext_plus/_figure.py +1295 -303
- plotext_plus/_global.py +238 -140
- plotext_plus/_matrix.py +217 -63
- plotext_plus/_monitor.py +1036 -489
- plotext_plus/_output.py +29 -23
- plotext_plus/_shtab.py +2 -0
- plotext_plus/_themes.py +363 -247
- plotext_plus/_utility.py +581 -313
- plotext_plus/api.py +418 -332
- plotext_plus/charts.py +47 -24
- plotext_plus/core.py +570 -177
- plotext_plus/mcp_cli.py +15 -13
- plotext_plus/mcp_server.py +842 -166
- plotext_plus/plotext_cli.py +414 -275
- plotext_plus/plotting.py +86 -70
- plotext_plus/themes.py +10 -13
- plotext_plus/utilities.py +33 -33
- plotext_plus/utils.py +240 -140
- {plotext_plus-1.0.8.dist-info → plotext_plus-1.0.10.dist-info}/METADATA +7 -2
- plotext_plus-1.0.10.dist-info/RECORD +33 -0
- plotext_plus-1.0.8.dist-info/RECORD +0 -33
- {plotext_plus-1.0.8.dist-info → plotext_plus-1.0.10.dist-info}/WHEEL +0 -0
- {plotext_plus-1.0.8.dist-info → plotext_plus-1.0.10.dist-info}/entry_points.txt +0 -0
- {plotext_plus-1.0.8.dist-info → plotext_plus-1.0.10.dist-info}/licenses/LICENSE +0 -0
plotext_plus/_output.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# /usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
2
|
|
|
4
3
|
# This file contains the output handling system using chuk-term
|
|
5
4
|
# It provides both the traditional direct output and new banner-based output modes
|
|
6
5
|
|
|
7
6
|
import sys
|
|
7
|
+
|
|
8
8
|
from chuk_term import ui
|
|
9
|
-
from rich.panel import Panel
|
|
10
9
|
from rich.console import Console
|
|
10
|
+
from rich.panel import Panel
|
|
11
11
|
from rich.text import Text
|
|
12
12
|
|
|
13
13
|
|
|
@@ -16,17 +16,17 @@ class PlotextOutput:
|
|
|
16
16
|
Unified output handler for plotext that supports both traditional
|
|
17
17
|
terminal output and chuk-term enhanced output with banners and themes.
|
|
18
18
|
"""
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def __init__(self, use_banners=False, banner_title=None):
|
|
21
21
|
self.use_banners = use_banners
|
|
22
22
|
self.banner_title = banner_title or "Plotext Chart"
|
|
23
23
|
self._buffer = []
|
|
24
24
|
self.console = Console()
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def write(self, content):
|
|
27
27
|
"""
|
|
28
28
|
Main output method that handles both traditional and banner-based output.
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
Args:
|
|
31
31
|
content (str): The content to output (typically the chart canvas)
|
|
32
32
|
"""
|
|
@@ -34,61 +34,60 @@ class PlotextOutput:
|
|
|
34
34
|
self._write_with_banner(content)
|
|
35
35
|
else:
|
|
36
36
|
self._write_direct(content)
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
def _write_direct(self, content):
|
|
39
39
|
"""Traditional direct output to stdout (maintains backward compatibility)"""
|
|
40
40
|
sys.stdout.write(content)
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
def _write_with_banner(self, content):
|
|
43
43
|
"""Output content within a chuk-term banner/panel using Rich panels"""
|
|
44
44
|
# Rich panels need consistent line widths for proper alignment
|
|
45
45
|
# We need to ensure all lines have exactly the same visible width
|
|
46
|
-
|
|
47
|
-
from rich.text import Text
|
|
48
|
-
|
|
46
|
+
|
|
49
47
|
# Convert content to Rich Text object to properly handle ANSI codes
|
|
50
48
|
# This ensures consistent width calculations
|
|
51
49
|
rich_text = Text.from_ansi(content)
|
|
52
|
-
|
|
50
|
+
|
|
53
51
|
# Create a Rich panel with the processed content
|
|
54
52
|
panel = Panel(
|
|
55
53
|
rich_text,
|
|
56
54
|
title=f"📊 {self.banner_title}",
|
|
57
55
|
border_style="bright_blue",
|
|
58
56
|
padding=(0, 1),
|
|
59
|
-
expand=False # Don't auto-expand, use content width
|
|
57
|
+
expand=False, # Don't auto-expand, use content width
|
|
60
58
|
)
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
# Use Rich console to print the panel
|
|
63
61
|
self.console.print() # Add spacing before
|
|
64
62
|
self.console.print(panel)
|
|
65
63
|
self.console.print() # Add spacing after
|
|
66
|
-
|
|
64
|
+
|
|
67
65
|
def _clean_ansi_codes(self, content):
|
|
68
66
|
"""Remove ANSI escape codes for cleaner display in Rich panels"""
|
|
69
67
|
import re
|
|
68
|
+
|
|
70
69
|
# This removes basic ANSI codes but preserves the chart structure
|
|
71
|
-
ansi_escape = re.compile(r
|
|
72
|
-
return ansi_escape.sub(
|
|
73
|
-
|
|
70
|
+
ansi_escape = re.compile(r"\x1b\[[0-9;]*[a-zA-Z]")
|
|
71
|
+
return ansi_escape.sub("", content)
|
|
72
|
+
|
|
74
73
|
def set_banner_mode(self, enabled, title=None):
|
|
75
74
|
"""Enable or disable banner mode"""
|
|
76
75
|
self.use_banners = enabled
|
|
77
76
|
if title:
|
|
78
77
|
self.banner_title = title
|
|
79
|
-
|
|
78
|
+
|
|
80
79
|
def info(self, message):
|
|
81
80
|
"""Output informational message using chuk-term"""
|
|
82
81
|
ui.info(message)
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
def success(self, message):
|
|
85
84
|
"""Output success message using chuk-term"""
|
|
86
85
|
ui.success(message)
|
|
87
|
-
|
|
86
|
+
|
|
88
87
|
def warning(self, message):
|
|
89
88
|
"""Output warning message using chuk-term"""
|
|
90
89
|
ui.warning(message)
|
|
91
|
-
|
|
90
|
+
|
|
92
91
|
def error(self, message):
|
|
93
92
|
"""Output error message using chuk-term"""
|
|
94
93
|
ui.error(message)
|
|
@@ -97,6 +96,7 @@ class PlotextOutput:
|
|
|
97
96
|
# Global output instance
|
|
98
97
|
_output = PlotextOutput()
|
|
99
98
|
|
|
99
|
+
|
|
100
100
|
def write(string):
|
|
101
101
|
"""
|
|
102
102
|
The main write function used by plotext (maintains API compatibility).
|
|
@@ -104,33 +104,39 @@ def write(string):
|
|
|
104
104
|
"""
|
|
105
105
|
_output.write(string)
|
|
106
106
|
|
|
107
|
+
|
|
107
108
|
def set_output_mode(use_banners=False, banner_title=None):
|
|
108
109
|
"""
|
|
109
110
|
Configure output mode for plotext.
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
Args:
|
|
112
113
|
use_banners (bool): Whether to use chuk-term banners
|
|
113
114
|
banner_title (str): Title for the banner (optional)
|
|
114
115
|
"""
|
|
115
116
|
_output.set_banner_mode(use_banners, banner_title)
|
|
116
117
|
|
|
118
|
+
|
|
117
119
|
def get_output_instance():
|
|
118
120
|
"""Get the global output instance for advanced usage"""
|
|
119
121
|
return _output
|
|
120
122
|
|
|
123
|
+
|
|
121
124
|
# Convenience functions for chuk-term output
|
|
122
125
|
def info(message):
|
|
123
126
|
"""Output info message via chuk-term"""
|
|
124
127
|
_output.info(message)
|
|
125
128
|
|
|
129
|
+
|
|
126
130
|
def success(message):
|
|
127
131
|
"""Output success message via chuk-term"""
|
|
128
132
|
_output.success(message)
|
|
129
133
|
|
|
134
|
+
|
|
130
135
|
def warning(message):
|
|
131
136
|
"""Output warning message via chuk-term"""
|
|
132
137
|
_output.warning(message)
|
|
133
138
|
|
|
139
|
+
|
|
134
140
|
def error(message):
|
|
135
141
|
"""Output error message via chuk-term"""
|
|
136
|
-
_output.error(message)
|
|
142
|
+
_output.error(message)
|