Skip to content

Commit c1c97aa

Browse files
committed
some documentation
1 parent 6cba80d commit c1c97aa

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@ A standalone JSON Schema based validator for XDI files used to save XAS data aim
66
As simple as it gets :
77

88
```python
9-
# import the
9+
# import the functionality from the module
1010
from 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
```

0 commit comments

Comments
 (0)