-
Notifications
You must be signed in to change notification settings - Fork 0
/
about_twice.py
64 lines (46 loc) · 1.44 KB
/
about_twice.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# __author__ = 'ames0k0'
from os import chdir
from time import sleep
from string import Template
from collections import Counter
from docs.config import artists, bio, DISCOGRAPHY, SOURCES, STATIC_DIR_ABOUT
from docs.config import purple, blue, end
from tools import fastprint, termin, reset_terminal
pfmt = ('$purple', '$end', '$blue', '$end')
bfmt = ('$blue', '$end', '$purple', '$end')
def count(x: str, v: str) -> int:
"""Return count of bio for coloring
"""
return Counter(x)[v]
def colored(task: str, col) -> str:
"""Make colored bio info
"""
conf = {'0': pfmt, '1': bfmt}
frmt = conf.get(col) * (count(task, '{') // 2)
to_template = Template(task.format(*frmt[:((count(task, '\n') - 3) * 2)]))
return to_template.substitute(purple=purple, blue=blue, end=end)
def main():
"""Print artists bio and pictures
"""
for artist in artists.keys():
fastprint(str(colored(bio % artists[artist], '0')))
sleep(1)
termin(3, artist + '.jpg')
break
fastprint(colored(DISCOGRAPHY, '1'))
sleep(1)
termin(3, 'TWICE.jpg')
fastprint(colored(SOURCES, '0'))
# to read info
sleep(3)
if __name__ == '__main__':
if not STATIC_DIR_ABOUT.exists():
STATIC_DIR_ABOUT.mkdir(parents=True, exist_ok=True)
chdir(STATIC_DIR_ABOUT)
try:
main()
except KeyboardInterrupt:
pass
reset_terminal()