File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed
Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,26 @@ A standalone JSON Schema based validator for XDI files used to save XAS data aim
66As simple as it gets :
77
88``` python
9- # import the
9+ # import the functionality from the module
1010from xdi_validator import validate, XDIEndOfHeaderMissingError
1111
12- xdi_document = open (' filename.xdi' , ' r' )
13- try :
14- xdi_errors, xdi_dict = validate(xdi_document)
15- except XDIEndOfHeaderMissingError as ex:
16- print (ex.message)
17-
18- if xdi_errors:
19- print (' XDI is invalid!' )
20- for error in xdi_errors:
21- print (error)
22- else :
23- print (' XDI is valid!' )
24- print (xdi_dict)
12+ # open the xdi file
13+ with open (' filename.xdi' , ' r' ) as xdi_document:
14+
15+ # Validate the file. If there is no end-of-header token
16+ # an exception is raised
17+ try :
18+ xdi_errors, xdi_dict = validate(xdi_document)
19+ except XDIEndOfHeaderMissingError as ex:
20+ print (ex.message)
21+
22+ # check if there are errors
23+ if xdi_errors:
24+ print (' XDI is invalid!' )
25+ for error in xdi_errors:
26+ print (error)
27+ else :
28+ print (' XDI is valid!' )
29+ print (xdi_dict)
2530
2631```
You can’t perform that action at this time.
0 commit comments