-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrealtime_fake_generator.py
More file actions
33 lines (29 loc) · 1.27 KB
/
realtime_fake_generator.py
File metadata and controls
33 lines (29 loc) · 1.27 KB
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
# -*- coding: utf-8 -*-
"""realtime base sender provider"""
from datetime import datetime
from .base_fake_generator import BaseFakeGenerator
class RealtimeFakeGenerator(BaseFakeGenerator):
"""Realtime fake data generation"""
def __init__(self, engine=None, template=None, **kwargs):
"""Realtime fake data generation"""
BaseFakeGenerator.__init__(self, engine=engine, template=template,
**kwargs)
def realtime_iteration(self, write_function=None):
"""Realtime function for parse and send/show generated data"""
while True:
lines = self.process().split('\n')
for line in lines:
if self.probability():
if not self.simulation:
write_function(line)
now = datetime.utcnow().ctime()
if self.verbose:
print('{0} => {1}'.format(now, str(line)))
else:
now = datetime.utcnow().ctime()
if self.verbose:
print('{0} => Skipped by prob.'.format(now))
if self.interactive:
input("» Press Enter for next iteration «")
else:
self.wait()