-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmolitvyPrint.py
53 lines (36 loc) · 1.32 KB
/
molitvyPrint.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
#py3.7
import sys
import time
import unicodedata
# https://stackoverflow.com/questions/61601610/removing-all-non-letter-chars-from-a-string-with-accents-in-python?rq=3
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')
def printMolitvu(textArray, times):
for num in range(0,times):
for t in textArray:
print(t)
time.sleep(0.05*len(t))
if __name__ == '__main__':
filename = "molitvySome.txt"
try:
with open(filename, encoding="utf8") as txt:
textToExtract =txt.read()
textAsArray = strip_accents(textToExtract).splitlines()
t = []
times = 0;
for s in textAsArray:
if(s == ''):
if t != []:
printMolitvu(t, times);
t = []
times = 0;
time.sleep(1)
elif (s[0] == '\t'):
for tabs in s:
if tabs == '\t':
times = times + 1
t.append(s)
except IOError:
print(f"can't open file {filename}")
input()