import json
def load_json(path):
"""load json object"""
with open(path, 'rb') as f:
data = json.load(f)
print("Loaded json from path: " + str(path))
return data
import difflib
def generate_diff_html(text_pairs, output_file=''):
diff_css = '''
'''
diff_html = '\n\n
\n\nText Diff\n'
diff_html += diff_css
diff_html += '\n\n\n'
for i, (text, text_processed) in enumerate(text_pairs, 1):
diff_html += f'Pair {i}
\n'
d = difflib.HtmlDiff()
diff_table = d.make_table(text.splitlines(), text_processed.splitlines())
diff_html += diff_table
diff_html += '
\n'
diff_html += '\n'
if output_file != '':
with open(output_file, 'w') as f:
f.write(diff_html)
return diff_html