in src/graph_notebook/magics/streams.py [0:0]
def show_records(self, records):
if len(records) > 0:
html = '''<html><body><table style="border: 1px solid black">'''
html += '''<tr>
<th style="text-align: center" title="The transaction or op number within a transaction">Tx/Op#</th>
<th style="text-align: center" title="The type of operation such as ADD or REMOVE">Operation</th>
<th style="text-align: center" title="Indicates if this is the final Op of a transaction. This feature requires a Neptune engine version of 1.1.1.0 or higher.">LastOp</th>
<th style="text-align: center;">Data</th>
</tr>'''
commit_num = None
for record in records:
current_commit_num = record['eventId']['commitNum']
timestamp = None
lastop = False
lastop_text = ''
if STREAM_COMMIT_TIMESTAMP in record:
timestamp = record[STREAM_COMMIT_TIMESTAMP]
utc_text = datetime.utcfromtimestamp(timestamp/1000)
data = json.dumps(record['data']).replace('&', '&').replace('<', '<')
if commit_num is None or current_commit_num != commit_num:
commit_num = current_commit_num
html += '<tr style="border: 1px solid black; background-color: gainsboro ; font-weight: bold;">'
html += '<td title="The commit number for this transaction" style="border: 1px solid black; vertical-align: top; text-align: left;" colspan="4">{}'.format(commit_num)
if timestamp != None:
html += ' Timestamp = {}'.format(timestamp)
html += ' ( {} UTC )'.format(utc_text)
html += '</td>'
html += '</tr><tr style="border: 1px solid black;">'
if STREAM_IS_LASTOP in record:
lastop = record[STREAM_IS_LASTOP]
if lastop:
lastop_text = 'Y'
html += '<tr style="border: 1px solid black; background-color: white;">'
html += '''<td title="The operation number within this transaction" style="border: 1px solid black; vertical-align: top;">{}</td>
<td title="The operation performed"style="border: 1px solid black; vertical-align: top;text-align: center;">{}</td>
<td title="A Y indicates the final Op for a transaction. Earlier Neptune versions do not support this option." style="border: 1px solid black; vertical-align: top;text-align: center;">{}</td>
<td title="Details of the change made by this operation" style="border: 1px solid black; vertical-align: top; text-align: left;">{}</td></tr>'''.format(
record['eventId']['opNum'],
record['op'],
lastop_text,
data)
html += '</table></body></html>'
self.out.clear_output(wait=True)
with self.out:
display(HTML(html))
else:
self.out.clear_output(wait=True)
with self.out:
display(HTML('<b>No records found to display</b>'))