Commit cbedd798 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Adapt error filter based on tags

parent e6dc8927
......@@ -101,13 +101,17 @@ def _extract_header_and_rows_from_frictionless_source(source, **source_options):
return rows[0], rows[1:]
BODY_TAGS = frozenset(["#body", "#cell", "#content", "#row", "#table"])
STRUCTURE_TAGS = frozenset(["#head", "#structure"])
def is_body_error(err: Union[frictionless.errors.Error, Dict]) -> bool:
"""Classify the given error as 'body error' according to its tags."""
tags = err.tags if isinstance(err, frictionless.errors.Error) else err["tags"]
return "#body" in tags or "#content" in tags
return bool(BODY_TAGS & set(tags))
def is_structure_error(err: Union[frictionless.errors.Error, Dict]) -> bool:
"""Classify the given error as 'structure error' according to its tags."""
tags = err.tags if isinstance(err, frictionless.errors.Error) else err["tags"]
return "#head" in tags or "#structure" in tags
return bool(STRUCTURE_TAGS & set(tags))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment