Guest User

Untitled

a guest
Oct 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import json
  3. import subprocess
  4. import os.path
  5. from glob import glob
  6. import difflib
  7.  
  8. for dash in glob('*.dashboard.py'):
  9. base = dash.split('.', 1)[0]
  10. json_filename = '{}-dashboard.json'.format(base)
  11. subprocess.check_call([
  12. 'generate-dashboard', dash, '-o', json_filename,
  13. ])
  14. with open(json_filename, 'rt') as f:
  15. got_dashboard = json.load(f)
  16.  
  17. got_dashboard_json = json.dumps(got_dashboard, sort_keys=True, indent=2)
  18.  
  19. with open(os.path.join('jsons', json_filename)) as f:
  20. ref_dashboard = json.load(f)
  21. ref_dashboard_json = json.dumps(ref_dashboard, indent=2, sort_keys=True)
  22.  
  23. differ = difflib.HtmlDiff(tabsize=2, wrapcolumn=80)
  24. html = differ.make_file(
  25. ref_dashboard_json.splitlines(), got_dashboard_json.splitlines()
  26. )
  27. with open('{}.diff.html'.format(base), 'wt') as f:
  28. f.write(html)
Add Comment
Please, Sign In to add comment