-
Notifications
You must be signed in to change notification settings - Fork 0
/
loltqdm.py
70 lines (55 loc) · 1.47 KB
/
loltqdm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from tqdm import tqdm
from localolcat import LolCat
class Options:
os = 0
animate = False
force = False
charset_py2 = 'utf-8'
spread = 3.0
freq = 0.1
duration = 12
speed = 20.0
mode = 16
class loltqdm(tqdm):
options = Options()
@classmethod
def status_printer(cls, file):
fp = file
fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover
def fp_write(s):
# fp.write(_unicode(s))
lolcat = LolCat()
lolcat.cat([s], cls.options)
fp_flush()
last_len = [0]
def print_status(s):
len_s = len(s)
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
last_len[0] = len_s
return print_status
def moveto(self, n):
self.options.os -= n
super(loltqdm, self).moveto(n)
# ORIGINAL
# @staticmethod
# def status_printer(file):
# """
# Manage the printing and in-place updating of a line of characters.
# Note that if the string is longer than a line, then in-place
# updating may not work (it will print a new line at each refresh).
# """
# fp = file
# fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover
#
# def fp_write(s):
#
# fp_flush()
#
# last_len = [0]
#
# def print_status(s):
# len_s = len(s)
# fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
# last_len[0] = len_s
#
# return print_status