Skip to content

Commit d4743b9

Browse files
committed
only validates files that end in jsonld or with no extensions
1 parent b227e12 commit d4743b9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: reproschema/tests/data/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file should be ingored during validation.

Diff for: reproschema/validate.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import os
2+
from pathlib import Path
23
from .utils import start_server, stop_server, lgr
34
from .jsonldutils import load_file, validate_data
45

56

67
def validate_dir(directory, shape_file, started=False, http_kwargs={}):
78
"""Validate a directory containing JSONLD documents
89
9-
.. warning:: This assumes every file in the directory can be read by a json parser.
10-
1110
Parameters
1211
----------
1312
directory: str
@@ -34,9 +33,17 @@ def validate_dir(directory, shape_file, started=False, http_kwargs={}):
3433
else:
3534
if "port" not in http_kwargs:
3635
raise KeyError(f"HTTP server started, but port key is missing")
37-
for root, dirs, files in os.walk(directory):
36+
37+
for root, _, files in os.walk(directory):
3838
for name in files:
3939
full_file_name = os.path.join(root, name)
40+
41+
if Path(full_file_name).suffix not in [".jsonld", ""]:
42+
lgr.info(f"Skipping file {full_file_name}")
43+
continue
44+
45+
lgr.debug(f"Validating file {full_file_name}")
46+
4047
try:
4148
data = load_file(full_file_name, started=True, http_kwargs=http_kwargs)
4249
if len(data) == 0:

0 commit comments

Comments
 (0)