|
3 | 3 | import re |
4 | 4 |
|
5 | 5 | from io import BytesIO |
6 | | -from jsonschema import Draft7Validator, draft7_format_checker, RefResolver |
| 6 | +from jsonschema import Draft7Validator, RefResolver |
7 | 7 | from lxml import etree |
8 | 8 | from urllib.request import pathname2url |
9 | 9 |
|
@@ -91,7 +91,8 @@ def run_json_validator(self, content_to_validate): |
91 | 91 | resolver = RefResolver.from_schema(schema, store=schema_store) |
92 | 92 |
|
93 | 93 | validator = Draft7Validator( |
94 | | - schema, format_checker=draft7_format_checker, resolver=resolver |
| 94 | + schema, |
| 95 | + format_checker=Draft7Validator.FORMAT_CHECKER, resolver=resolver |
95 | 96 | ) |
96 | 97 |
|
97 | 98 | for error in sorted( |
@@ -136,13 +137,13 @@ def _build_errors(error_log, paths): |
136 | 137 | # For DIF, because the namespace is specified in the metadata file, lxml library |
137 | 138 | # provides field name concatenated with the namespace, |
138 | 139 | # the following 3 lines of code removes the namespace |
139 | | - namespaces = re.findall("(\{http[^}]*\})", line) |
| 140 | + namespaces = re.findall(r"(\{http[^}]*\})", line) |
140 | 141 | for namespace in namespaces: |
141 | 142 | line = line.replace(namespace, "") |
142 | | - field_name = re.search("Element\s'(.*)':", line)[1] |
| 143 | + field_name = re.search(r"Element\s'(.*)':", line)[1] |
143 | 144 | field_paths = [abs_path for abs_path in paths if field_name in abs_path] |
144 | 145 | field_name = field_paths[0] if len(field_paths) == 1 else field_name |
145 | | - message = re.search("Element\s'.+':\s(\[.*\])?(.*)", line)[2].strip() |
| 146 | + message = re.search(r"Element\s'.+':\s(\[.*\])?(.*)", line)[2].strip() |
146 | 147 | errors.setdefault(field_name, {})["schema"] = { |
147 | 148 | "message": [f"Error: {message}"], |
148 | 149 | "valid": False, |
|
0 commit comments