-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetquoteclient.py
executable file
·51 lines (42 loc) · 1.27 KB
/
getquoteclient.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
from getquote import quoteoftheday
qml = 85 #Quote Max Lenght - can be set by caller for example.
qll = qml +1
while qll >= qml:
quote = quoteoftheday()
qll = len(quote.quote_text)
print("******************************")
print("getting a quote under "+str(qml)+" lenght")
print("current lenght is "+str(qll)+"\n")
print("final lenght is "+str(qll))
#print("Now trying to slice the text in chunks")
text_max = len(quote.quote_text)
text_line_max = 34 # Max number of chars per line
text_line = []
textbuffer = ""
#Split the quote into words in an array
quote_words = quote.quote_text.split()
# print(quote_words)
wl = len(quote.quote_text)
#See if the total is larger than the text_line_max value set.
if text_max > text_line_max:
l = 0
ql = len(quote_words)
while l < ql:
textbuffer = textbuffer + quote_words[l] + " "
l += 1
#print(textbuffer)
if len(textbuffer) > text_line_max:
text_line.append(textbuffer)
textbuffer = ""
#print(l)
if (len(textbuffer)):
text_line.append(textbuffer)
else :
text_line.append(quote.quote_text)
# Get number of arrays generated
qs = len(text_line)
qc = 0
while qc < qs:
print(text_line[qc])
qc += 1
print("- "+quote.quote_author)