Add a simple displayer of verapdf output.
parent
38f96ca6d3
commit
d4c62b0576
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from os import system
|
||||
import xml.etree.ElementTree as ET
|
||||
import pathlib
|
||||
|
||||
def _colorize(color, *a, **kwa):
|
||||
system(f'tput setaf {color}')
|
||||
print(*a, **kwa)
|
||||
system('tput sgr0')
|
||||
|
||||
def green(*a, **kwa): return _colorize(2, *a, **kwa)
|
||||
def red(*a, **kwa): return _colorize(1, *a, **kwa)
|
||||
|
||||
root = ET.parse('verapdf_report.xml').getroot()
|
||||
for job in root.findall('./jobs/job'):
|
||||
file = job.find('./item/name').text
|
||||
file = pathlib.Path(file).name
|
||||
result = job.find('./validationReport')
|
||||
ok = result.attrib[r'isCompliant'] == 'true'
|
||||
resstr = result.attrib[r'statement']
|
||||
print(f'{file}: ', end='', flush=True)
|
||||
display = green if ok else red
|
||||
display(resstr)
|
Loading…
Reference in New Issue