-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2.py
37 lines (35 loc) · 1.2 KB
/
example2.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
import time
import random
from faker import Faker
from list2term import Lines
def main():
print('Generating random sentences...')
docgen = Faker()
with Lines(data=[''] * 10, max_chars=100) as lines:
for _ in range(100):
index = random.randint(0, len(lines) - 1)
lines[index] = docgen.sentence()
for _ in range(100):
update = ['update'] * 18
append = ['append'] * 18
pop = ['pop'] * 14
clear = ['clear']
choice = random.choice(append + pop + clear + update)
if choice == 'pop':
if len(lines) > 0:
index = random.randint(0, len(lines) - 1)
lines.pop(index)
elif choice == 'append':
lines.append(docgen.sentence())
elif choice == 'update':
if len(lines) > 0:
index = random.randint(0, len(lines) - 1)
lines[index] = docgen.sentence()
else:
if len(lines) > 0:
lines.pop()
if len(lines) > 0:
lines.pop()
time.sleep(.05)
if __name__ == '__main__':
main()