Skip to content

Commit 7ba6468

Browse files
committed
Simplify progress bar pattern to cover more cases
Use simple dotted line for progress bars. More lightweight in appearance and encoding-neutral.
1 parent d719be2 commit 7ba6468

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

diff-logs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
r'[a-zA-Z0-9]{18,}': 'AAAAAAAAAAAAAAAAAA', # Long payload
3737
r'[a-fA-F0-9]{7,}': 'd1ff1065', # Hash digest
3838
# Progress bar, e.g. in pip, tqdm
39-
r'^(?P<indent>[ \t]*)(?P<pct>\d+%\|)?'
40-
r'(?P<symbol>[━=█])(?P=symbol){4,} *(?(pct)\||)'
41-
r'(?:[ \d.,:/\][<]|(?:MB|kB|B|it)(?:/s)?|eta)*': r'\g<indent>━━━━━',
39+
r'(?P<indent>[ \t]*)(?: *(?:\[ *)?\d+%(?:])? *)?[[|]?[\u2500-\u259f=.-]{5,} *[\]|]?(?: *(?:\[ *)?\d+%(?:])? *)?[(]?[\d.KMGB ]+/.*': r'\g<indent>.......', # noqa: E501
4240
}
4341

4442
assert all(re.match(fr'\A(?:{p})\Z', v)

tests/test.in.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ AF09AF09
6464

6565
# Progress bar
6666
━━━━━━━━━━━━━━ 73.5/73.5 kB 5.9 MB/s eta 0:00:00
67-
100%|===========| eta
68-
76%|████████████████████████ | 756/1000 [00:33<00:10, 20.0it/s]
67+
76%|████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]
68+
[ 32%] [███████████.................] 12.3MB/38.4MB
69+
45% ━━━━━━━▍ 1.2MB/2.7MB
70+
━━━━━━━━━ 12.3/73.5 MB 16.7% eta 0:00:10
71+
|██████████████████████------| 72% (574/800)

tests/test.out.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ d1ff1065
6363
d1ff1065
6464

6565
# Progress bar
66-
━━━━━
67-
━━━━━
68-
━━━━━
66+
.......
67+
.......
68+
.......
69+
.......
70+
.......
71+
.......

0 commit comments

Comments
 (0)