Skip to content

Commit 7939bdc

Browse files
authored
Merge pull request #325 from NASA-IMPACT/entrytitle-la
Entrytitle - Revised
2 parents 312869c + 7bc72ac commit 7939bdc

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

pyQuARC/code/schema_validator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def run_json_validator(self, content_to_validate):
172172
errors = {}
173173
resolver = RefResolver.from_schema(schema, store=schema_store)
174174
validator = Draft7Validator(
175-
schema, format_checker=Draft7Validator.FORMAT_CHECKER, resolver=resolver
175+
schema,
176+
format_checker=Draft7Validator.FORMAT_CHECKER, resolver=resolver
176177
)
177178

178179
for error in sorted(
@@ -220,7 +221,7 @@ def _build_errors(error_log, paths):
220221
namespaces = re.findall(r"(\{http[^}]*\})", line)
221222
for namespace in namespaces:
222223
line = line.replace(namespace, "")
223-
field_name = re.search(r"Element\s'(.*)':", line)[1]
224+
field_name = re.search(r"Element\s'(.*)':", line)[1]
224225
field_paths = [abs_path for abs_path in paths if field_name in abs_path]
225226
field_name = field_paths[0] if len(field_paths) == 1 else field_name
226227
message = re.search(r"Element\s'.+':\s(\[.*\])?(.*)", line)[2].strip()

pyQuARC/code/string_validator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .base_validator import BaseValidator
22
from .gcmd_validator import GcmdValidator
33
from .utils import cmr_request, collection_in_cmr, if_arg, set_cmr_prms
4-
4+
import re
55

66
class StringValidator(BaseValidator):
77
"""
@@ -38,15 +38,21 @@ def length_check(string, extent, relation):
3838
def compare(first, second, relation):
3939
"""
4040
Compares two strings based on the relationship
41-
4241
Returns:
43-
(dict) An object with the validity of the check and the instance
42+
(dict) An object with the validity of the check and the instance
4443
"""
44+
45+
# Check if 'first' and 'second' contain any special characters
46+
first_clean = re.sub(r'[^a-zA-Z0-9]', '', first).upper()
47+
second_clean = re.sub(r'[^a-zA-Z0-9]', '', second).upper()
48+
49+
# If either string contains special characters, return a warning or handle as needed
4550
return {
46-
"valid": BaseValidator.compare(first.upper(), second.upper(), relation),
51+
"valid": BaseValidator.compare(first_clean, second_clean, relation),
4752
"value": (first, second),
4853
}
4954

55+
5056
@staticmethod
5157
@if_arg
5258
def controlled_keywords_check(value, keywords_list):

pyQuARC/schemas/check_messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"message": "",
6262
"url": "https://wiki.earthdata.nasa.gov/display/CMR/Entry+Title"
6363
},
64-
"remediation": "The EntryTitle/DataSetId should not be identical to the ShortName. Recommend providing a descriptive, formal title for the dataset. "
64+
"remediation": "Recommend providing a more descriptive title for the dataset. "
6565
},
6666
"abstract_length_check": {
6767
"failure": "The abstract provided may be inadequate based on length.",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
{}
2+

tests/test_downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class TestDownloader:
99
def setup_method(self):
1010
self.concept_ids = {
1111
"collection": {
12-
"real": "C1000000010-CDDIS",
12+
"real": "C1000000042-CDDIS",
1313
"dummy": "C123456-LPDAAC_ECS",
1414
},
1515
"granule": {
16-
"real": "G1001434969-CDDIS",
16+
"real": "G1018577631-CDDIS",
1717
"dummy": "G1000000002-CMR_PROV",
1818
},
1919
"invalid": "asdfasdf",

0 commit comments

Comments
 (0)