Skip to content

Commit

Permalink
Added idea of wildcard option in vocab check
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-hampton committed Nov 4, 2022
1 parent 8f6fb41 commit 6c5b8a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 10 additions & 2 deletions checksit/cvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
vocabs_dir = conf["settings"]["vocabs_dir"]
vocabs_prefix = conf["settings"]["vocabs_prefix"]

WILDCARD = ["__all__"]


class Vocabs:
def __init__(self):
Expand All @@ -33,8 +35,14 @@ def lookup(self, vocab_lookup):
obj = self
vocab_lookup = re.sub(f"^{vocabs_prefix}:", "", vocab_lookup)

for key in vocab_lookup.split(":"):
obj = obj[key]
for i,key in enumerate(vocab_lookup.split(":")):
if key in WILDCARD:
if i+1 != len(vocab_lookup.split(":")):
raise ValueError(f"WILDCARD {key} only allowed as last argument")
else:
obj = list(obj.keys())
else:
obj = obj[key]

return obj

Expand Down
5 changes: 2 additions & 3 deletions specs/groups/amof-global-attrs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ required-global-attrs:
func: checksit.generic.check_global_attrs
params:
vocab_attrs:
source: __vocab__:EDIT:Exact match in vocabulary
platform: __vocab__:EDIT:Exact match in vocabulary
#source: __vocabs__:AMF_CVs/AMF_ncas_instrument:ncas_instrument:__all__:description
platform: __vocabs__:AMF_CVs/AMF_platform:platform:__all__
rules_attrs:
Conventions: regex:CF-1.6,\sNCAS-AMF-2.0.0
instrument_manufacturer: rule-func:string-of-length:2+
Expand Down Expand Up @@ -38,7 +38,6 @@ required-global-attrs:
time_coverage_start: regex-rule:datetime
time_coverage_end: regex-rule:datetime
geospatial_bounds: rule-func:string-of-length:8+
platform_altitude: regex-rule:EDIT:Exact match: <number> m
location_keywords: rule-func:string-of-length:3+
amf_vocabularies_release: regex-rule:valid-url
history: rule-func:string-of-length:1+
Expand Down

0 comments on commit 6c5b8a0

Please sign in to comment.