Skip to content

Commit 2231c87

Browse files
Ghesselinkaothms
authored andcommitted
remove data_only validation (header is preq for syntax check)
1 parent 502cc33 commit 2231c87

File tree

3 files changed

+2
-41
lines changed

3 files changed

+2
-41
lines changed

__init__.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,7 @@ def parse(
334334
with_tree=True,
335335
with_header=False,
336336
only_header=False,
337-
validate_data_only=False
338337
):
339-
if validate_data_only: # Used by the Validation Service to validate only the data section of an IFC file, ignoring the header.
340-
only_header = False
341-
with_header = False
342-
with_tree= False
343338
if filename:
344339
assert not filecontent
345340
filecontent = builtins.open(filename, encoding=None).read()
@@ -412,20 +407,8 @@ def replace_fn(match):
412407

413408
NT = type("NullTransformer", (Transformer,), methods)
414409
transformer = {"transformer": NT()}
415-
416-
if validate_data_only:
417-
match = re.search(
418-
r"DATA\s*;(.*?)ENDSEC\s*;",
419-
filecontent_wo_comments,
420-
flags=re.DOTALL | re.IGNORECASE,
421-
)
422-
if not match:
423-
raise ValidationError("No DATA section found in file")
424-
filecontent_wo_comments = f"DATA;{match.group(1)}ENDSEC;"
425-
start_rule = "data_section"
426-
else:# Parse entire file (header + data)
427-
start_rule = "file"
428-
parser = Lark(grammar, parser="lalr", start=start_rule, **transformer)
410+
411+
parser = Lark(grammar, parser="lalr", start="file", **transformer)
429412

430413
try:
431414
ast = parser.parse(filecontent_wo_comments)

__main__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def main():
99
parser.add_argument("--progress", action="store_true", help="Show progress during validation.")
1010
parser.add_argument("--json", action="store_true", help="Output errors in JSON format.")
1111
parser.add_argument("--only-header", action="store_true", help="Validate only the header section.")
12-
parser.add_argument("--only-data", action="store_true", help="Validate only the data section.")
1312

1413
args = parser.parse_args()
1514
if args.only_header and args.only_data:
@@ -22,7 +21,6 @@ def main():
2221
with_progress = args.progress,
2322
with_tree = False,
2423
only_header=args.only_header,
25-
validate_data_only = args.only_data
2624
)
2725
if not args.json:
2826
print("Valid", file=sys.stderr)

test_parser.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,3 @@ def test_valid_headers(filename):
126126
# error in body; with_header should not raise an error
127127
with nullcontext():
128128
parse(filename=filename, with_tree=False, only_header=True, with_header=True)
129-
130-
131-
@pytest.mark.parametrize("filename", [
132-
'fixtures/fail_invalid_header_entity.ifc',
133-
'fixtures/fail_no_header.ifc',
134-
])
135-
def test_invalid_headers_(filename):
136-
# error in header; validate_data_only should not raise an error
137-
with nullcontext():
138-
parse(filename=filename, validate_data_only=True)
139-
140-
@pytest.mark.parametrize("filename", [
141-
'fixtures/fail_duplicate_id.ifc',
142-
'fixtures/fail_double_comma.ifc',
143-
'fixtures/fail_double_semi.ifc'
144-
])
145-
def test_valid_headers(filename):
146-
# error in body; validate_data_only should raise an error
147-
with pytest.raises(ValidationError):
148-
parse(filename=filename, validate_data_only=True)

0 commit comments

Comments
 (0)