hsolbrig / PyShEx

ShEx interpreter for ShEx 2.0
Creative Commons Zero v1.0 Universal
25 stars 10 forks source link

Need a formatting function for EvaluationResults #57

Open hsolbrig opened 5 years ago

hsolbrig commented 5 years ago

We need a consistent pretty-printer (__str__?) for EvaluationResults. Example from biolinkml:

def shex_results_as_string(rslts: EvaluationResult) -> str:
    """ Pretty print ShEx Evaluation result """
    # TODO: Add this method to ShEx itself
    rval = [f"Evalutating: {str(rslts.focus)} against {str(rslts.start)}"]
    if rslts.result:
        rval.append("Result: CONFORMS")
    else:
        rval.append("Result: NonConforming")
    rval += rslts.reason.split('\n')
    return '\n'.join(rval)