logbar 0.2.2__tar.gz → 0.2.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.4
2
2
  Name: LogBar
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A unified Logger and ProgressBar util with zero dependencies.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -38,6 +38,7 @@ Dynamic: license-file
38
38
  - Stackable progress bars that stay anchored while your logs flow freely.
39
39
  - Built-in styling for progress bar fills, colors, gradients, and head glyphs.
40
40
  - Animated progress titles with a subtle sweeping highlight.
41
+ Set `LOGBAR_ANIMATION=0` to disable the highlight animation.
41
42
  - Column-aware table printer with spans, width hints, and `fit` sizing.
42
43
  - Zero dependencies; works anywhere Python runs.
43
44
 
@@ -143,7 +144,7 @@ with log.spinner("Loading model") as spinner:
143
144
  warm_up()
144
145
  ```
145
146
 
146
- The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager.
147
+ The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager. Set `LOGBAR_ANIMATION=0` to disable the title highlight sweep on progress labels.
147
148
 
148
149
  ### Multiple Progress Bars
149
150
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LogBar
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A unified Logger and ProgressBar util with zero dependencies.
5
5
  Author-email: ModelCloud <qubitium@modelcloud.ai>
6
6
  License-Expression: Apache-2.0
@@ -38,6 +38,7 @@ Dynamic: license-file
38
38
  - Stackable progress bars that stay anchored while your logs flow freely.
39
39
  - Built-in styling for progress bar fills, colors, gradients, and head glyphs.
40
40
  - Animated progress titles with a subtle sweeping highlight.
41
+ Set `LOGBAR_ANIMATION=0` to disable the highlight animation.
41
42
  - Column-aware table printer with spans, width hints, and `fit` sizing.
42
43
  - Zero dependencies; works anywhere Python runs.
43
44
 
@@ -143,7 +144,7 @@ with log.spinner("Loading model") as spinner:
143
144
  warm_up()
144
145
  ```
145
146
 
146
- The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager.
147
+ The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager. Set `LOGBAR_ANIMATION=0` to disable the title highlight sweep on progress labels.
147
148
 
148
149
  ### Multiple Progress Bars
149
150
 
@@ -23,6 +23,7 @@
23
23
  - Stackable progress bars that stay anchored while your logs flow freely.
24
24
  - Built-in styling for progress bar fills, colors, gradients, and head glyphs.
25
25
  - Animated progress titles with a subtle sweeping highlight.
26
+ Set `LOGBAR_ANIMATION=0` to disable the highlight animation.
26
27
  - Column-aware table printer with spans, width hints, and `fit` sizing.
27
28
  - Zero dependencies; works anywhere Python runs.
28
29
 
@@ -128,7 +129,7 @@ with log.spinner("Loading model") as spinner:
128
129
  warm_up()
129
130
  ```
130
131
 
131
- The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager.
132
+ The rolling bar animates automatically while attached. Close it explicitly with `spinner.close()` if you are not using the context manager. Set `LOGBAR_ANIMATION=0` to disable the title highlight sweep on progress labels.
132
133
 
133
134
  ### Multiple Progress Bars
134
135
 
@@ -4,6 +4,7 @@
4
4
  # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
5
 
6
6
  import datetime
7
+ import os
7
8
  import re
8
9
  import sys
9
10
  import time
@@ -11,6 +12,7 @@ import threading
11
12
  from contextlib import contextmanager, nullcontext
12
13
  from dataclasses import dataclass, replace
13
14
  from enum import Enum
15
+ from functools import lru_cache
14
16
  from typing import Iterable, Optional, Union, TYPE_CHECKING, Sequence
15
17
  from warnings import warn
16
18
 
@@ -74,6 +76,12 @@ def _iter_ansi_tokens(text: str):
74
76
  i += 1
75
77
 
76
78
 
79
+ @lru_cache(maxsize=1)
80
+ def _env_animation_enabled() -> bool:
81
+ value = os.environ.get("LOGBAR_ANIMATION", "1")
82
+ return str(value).strip().lower() not in {"0", "false", "off", "no"}
83
+
84
+
77
85
  def _fg_256(code: int) -> str:
78
86
  return f"\033[38;5;{code}m"
79
87
 
@@ -878,6 +886,8 @@ class ProgressBar:
878
886
  return ''.join(result)
879
887
 
880
888
  def _should_animate_title(self) -> bool:
889
+ if not _env_animation_enabled():
890
+ return False
881
891
  isatty = getattr(sys.stdout, "isatty", None)
882
892
  if not callable(isatty):
883
893
  return False
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "LogBar"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "A unified Logger and ProgressBar util with zero dependencies."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3"
@@ -3,6 +3,7 @@
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  # Contact: qubitium@modelcloud.ai, x.com/qubitium
5
5
 
6
+ import subprocess
6
7
  import random
7
8
  import re
8
9
  import sys
@@ -139,6 +140,36 @@ class TestProgress(unittest.TestCase):
139
140
  with redirect_stdout(StringIO()):
140
141
  pb.close()
141
142
 
143
+ def test_title_animation_respects_logbar_animation_env(self):
144
+ script = (
145
+ "from types import SimpleNamespace\n"
146
+ "import sys\n"
147
+ "from logbar.progress import ProgressBar\n"
148
+ "pb = ProgressBar(range(1)).manual()\n"
149
+ "sys.stdout = SimpleNamespace(isatty=lambda: True, write=lambda *_: None, flush=lambda: None)\n"
150
+ "sys.__stdout__.write('1\\n' if pb._should_animate_title() else '0\\n')\n"
151
+ )
152
+
153
+ enabled = subprocess.run(
154
+ [sys.executable, "-c", script],
155
+ cwd="/root/LogBar",
156
+ capture_output=True,
157
+ text=True,
158
+ env={},
159
+ check=True,
160
+ )
161
+ self.assertEqual(enabled.stdout.strip(), "1")
162
+
163
+ disabled = subprocess.run(
164
+ [sys.executable, "-c", script],
165
+ cwd="/root/LogBar",
166
+ capture_output=True,
167
+ text=True,
168
+ env={"LOGBAR_ANIMATION": "0"},
169
+ check=True,
170
+ )
171
+ self.assertEqual(disabled.stdout.strip(), "0")
172
+
142
173
  def test_draw_respects_terminal_width(self):
143
174
  pb = log.pb(100).title("TITLE").subtitle("SUBTITLE").manual()
144
175
  pb.current_iter_step = 50
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes