diff --git a/checksit/rules/rule_funcs.py b/checksit/rules/rule_funcs.py index 009e9f42..af5b3538 100644 --- a/checksit/rules/rule_funcs.py +++ b/checksit/rules/rule_funcs.py @@ -220,13 +220,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=""): """ diff --git a/specs/groups/ncas-image-v1.0/amof-image-global-attrs.yml b/specs/groups/ncas-image-v1.0/amof-image-global-attrs.yml index bd7dca20..63556fa2 100644 --- a/specs/groups/ncas-image-v1.0/amof-image-global-attrs.yml +++ b/specs/groups/ncas-image-v1.0/amof-image-global-attrs.yml @@ -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-warning:ncas-email, regex-rule:valid-email