Skip to content

Commit 9e137c1

Browse files
committed
change check_list.txt to python file
1 parent ccd7df0 commit 9e137c1

20 files changed

+194
-1158
lines changed

src/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
recursive-include validator *.txt
1+
recursive-include rocrateValidator *.txt
22
recursive-include test/samples/invalid *.json
33
recursive-include test/samples/valid/ *.
44
recursive-include test/samples/valid/ *.html

src/__init__.py

Whitespace-only changes.

src/check_list.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def get_check_list():
2+
check_list = ["File existence",
3+
"File size",
4+
"Metadata file existence",
5+
"Json check",
6+
"Json-ld check",
7+
"RDF triples",
8+
"File descriptor check",
9+
"Direct property check",
10+
"Referencing check",
11+
"Encoding check",
12+
"Web-based data entity check",
13+
"Person entity check",
14+
"Organization entity check",
15+
"Contact information check",
16+
"Citation property check",
17+
"Publisher property check",
18+
"Funder property check",
19+
"Licensing property check",
20+
"Places property check",
21+
"Time property check",
22+
"Scripts and workflow check"
23+
]
24+
return check_list
25+
26+
# "File existence"
27+
# "File size"
28+
# "Metadata file existence"
29+
# "Json check"
30+
# "Json-ld check"
31+
# "RDF triples"
32+
# "File descriptor check"
33+
# "Direct property check"
34+
# "Referencing check"
35+
# "Encoding check"
36+
# "Web-based data entity check"
37+
# "Person entity check"
38+
# "Organization entity check"
39+
# "Contact information check"
40+
# "Citation property check"
41+
# "Publisher property check"
42+
# "Funder property check"
43+
# "Licensing property check"
44+
# "Places property check"
45+
# "Time property check"
46+
# "Scripts and workflow check"

src/directory/ro-crate-metadata copy.json

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/result.json

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/rocrateValidator/check_list.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def get_check_list():
2+
check_list = ["File existence",
3+
"File size",
4+
"Metadata file existence",
5+
"Json check",
6+
"Json-ld check",
7+
"RDF triples",
8+
"File descriptor check",
9+
"Direct property check",
10+
"Referencing check",
11+
"Encoding check",
12+
"Web-based data entity check",
13+
"Person entity check",
14+
"Organization entity check",
15+
"Contact information check",
16+
"Citation property check",
17+
"Publisher property check",
18+
"Funder property check",
19+
"Licensing property check",
20+
"Places property check",
21+
"Time property check",
22+
"Scripts and workflow check"
23+
]
24+
return check_list
25+
26+
# "File existence"
27+
# "File size"
28+
# "Metadata file existence"
29+
# "Json check"
30+
# "Json-ld check"
31+
# "RDF triples"
32+
# "File descriptor check"
33+
# "Direct property check"
34+
# "Referencing check"
35+
# "Encoding check"
36+
# "Web-based data entity check"
37+
# "Person entity check"
38+
# "Organization entity check"
39+
# "Contact information check"
40+
# "Citation property check"
41+
# "Publisher property check"
42+
# "Funder property check"
43+
# "Licensing property check"
44+
# "Places property check"
45+
# "Time property check"
46+
# "Scripts and workflow check"

src/rocrateValidator/semanticCheck.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import os
22
import json
33
import datetime
4-
from validator.utils import Result as Result
4+
from rocrateValidator.utils import Result as Result
55
import zipfile
66
import rocrate.utils as utils
77
import rocrate.rocrate as rocrate
88
from datetime import datetime
9+
import rocrateValidator.workflow_extension as we
910
import pytest
10-
# from utils import Result as Result
11-
1211

1312
correct_value = {
1413
"contactPoint":"ContactPoint",
@@ -337,10 +336,10 @@ def url_check(item, entityProp, metadata, result, error_message):
337336
if item == "citation":
338337
result[entityProp] = [False, error_message["IDError"].format(entityProp)]
339338

340-
def get_entity(item, entity, metadata, result, error_message, further_check = False, urlVal_required = False):
339+
def get_entity(item, entity, metadata, result, error_message, is_multipleEntity = False, urlVal_required = False):
341340

342341
"""
343-
The Boolean further check is to find the further referencing data entity.
342+
The Boolean is_multipleEntity is to find the further referencing data entity.
344343
The urlVal_required is for those data entity requiring the value of specific property is url.
345344
At this stage, there are only three differnet cases.
346345
For more generic, more specific situation should be specified.
@@ -349,14 +348,14 @@ def get_entity(item, entity, metadata, result, error_message, further_check = Fa
349348
entity_property = utils.get_norm_value(entity, item)
350349
if entity_property != []:
351350
for entityProp in entity_property:
352-
if urlVal_required and not further_check:
351+
if urlVal_required and not is_multipleEntity:
353352
url_check(item, entityProp, metadata, result, error_message)
354-
elif further_check:
355-
upd_result(item, entityProp, metadata, result, error_message, further_check = True)
353+
elif is_multipleEntity:
354+
upd_result(item, entityProp, metadata, result, error_message, is_multipleEntity = True)
356355
else:
357356
upd_result(item, entityProp, metadata, result, error_message)
358357

359-
def upd_result(item, entity_property, metadata, result, error_message, further_check = False, urlVal_required = False):
358+
def upd_result(item, entity_property, metadata, result, error_message, is_multipleEntity = False, urlVal_required = False):
360359
try:
361360
referencing_entity = metadata[entity_property]
362361
type = utils.get_norm_value(referencing_entity, "@type")
@@ -367,7 +366,7 @@ def upd_result(item, entity_property, metadata, result, error_message, further_c
367366
else:
368367
result[entity_property] = [False, error_message["TypeError"].format(entity_property)]
369368

370-
if further_check:
369+
if is_multipleEntity:
371370
if item == "author" or item == "publisher":
372371
get_entity("contactPoint", referencing_entity, metadata, result, error_message)
373372
else:
@@ -734,7 +733,7 @@ def scripts_and_workflow_check(tar_file, extension):
734733
"""
735734

736735
NAME = "Scripts and workflow check"
737-
wkfext_path = '/Users/xuanqili/Desktop/ro-crate-validator-py/src/workflow_extension.txt'
736+
# wkfext_path = '/Users/xuanqili/Desktop/ro-crate-validator-py/src/workflow_extension.txt'
738737

739738
error_message = {
740739
"WorkflowError":"Scripts and Workflow is Wrong",
@@ -752,8 +751,9 @@ def scripts_and_workflow_check(tar_file, extension):
752751
### check if recognised workflow file meets the requirments
753752
for entity in metadata.values():
754753
id_ = utils.get_norm_value(entity, "@id")[0]
755-
with open (wkfext_path, "r") as file:
756-
extension_set = file.read().splitlines()
754+
extension_set = list(we.get_workflow_extension())
755+
# with open (wkfext_path, "r") as file:
756+
# extension_set = file.read().splitlines()
757757
recognisedWkf_upd(extension_set, entity, workflow_result, id_, error_message)
758758

759759
### check unrecognised workflow file with ComputaionalWorkflow in its @type

0 commit comments

Comments
 (0)