Skip to content

Commit

Permalink
#35 platform controlled vocab check
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanrahan16 committed Sep 1, 2023
1 parent f7cc17a commit 6f98d3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion checksit/rules/rule_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,34 @@ def title_instrument(value, context, extras=None, label=""):
#if instrument not in data['ncas_instrument'][*]['description']:
#if instrument not in descriptn:
if instrument not in data['ncas_instrument']:
warnings.append(f"{label} '{value}' should be contained in the instrument controlled vocabulary list")
warnings.append(f"{label} '{instrument}' should be contained in the instrument controlled vocabulary list")

# Closing file
f.close()

return warnings

def title_platform(value, context, extras=None, label=""):
"""
A function to check if the platform in the title is contained in the controlled vocabulary list
"""
warnings = []

platform = value.split("_")[1]

# open JSON controlled vocab file:
g = open ('./checksit/vocabs/AMF_CVs/2.0.0/AMF_platform.json', "r")

## Reading from file:
data = json.loads(g.read())

if platform not in data['platform']:
warnings.append(f"{label} '{platform}' should be contained in the platform controlled vocabulary list")

# Closing file
g.close()

return warnings

def url_checker(value, context, extras=None, label=""):
"""
Expand Down
2 changes: 1 addition & 1 deletion specs/groups/ncas-image-v1.0/amof-image-global-attrs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ required-global-attrs:
XMP-xmpRights:WebStatement: regex-warning:http://www.nationalarchives.gov.uk/doc/open-government-licence/
XMP-photoshop:Credit: regex-warning:National\sCentre\sfor\sAtmospheric\sScience\s\(NCAS\)
# Source of the image
XMP-dc:Title: regex-rule:title-data-product, rule-func:title_check, rule-func-warning:title_instrument
XMP-dc:Title: regex-rule:title-data-product, rule-func:title_check, rule-func-warning:title_instrument, rule-func-warning:title_platform
# Instrument Scientist’s Details
XMP-dc:Creator: rule-func-warning:list_of_names
XMP-iptcCore:CreatorWorkEmail: regex-rule:work-email
Expand Down

0 comments on commit 6f98d3f

Please sign in to comment.