@@ -393,7 +393,6 @@ def validate_metadata(json_record):
393393 """
394394 errors = []
395395
396-
397396 if "titles" not in json_record :
398397 errors .append ("'titles' field is missing." )
399398 elif not isinstance (json_record ["titles" ], list ) or len (json_record ["titles" ]) == 0 :
@@ -467,7 +466,6 @@ def validate_metadata(json_record):
467466 "Each subject must be a dictionary with a 'subject' key."
468467 )
469468
470-
471469 # Check for 'relatedIdentifiers'
472470 if "relatedIdentifiers" in json_record :
473471 if not isinstance (json_record ["relatedIdentifiers" ], list ):
@@ -483,7 +481,6 @@ def validate_metadata(json_record):
483481 "Each relatedIdentifier must be a dictionary with a 'relatedIdentifier' key."
484482 )
485483
486-
487484 # Check for 'rightsList'
488485 if "rightsList" in json_record :
489486 if not isinstance (json_record ["rightsList" ], list ):
@@ -512,23 +509,39 @@ def validate_metadata(json_record):
512509 errors .append ("'dates' should be a non-empty list." )
513510 else :
514511 for date in json_record ["dates" ]:
515- if not isinstance (date , dict ) or "date" not in date or "dateType" not in date :
512+ if (
513+ not isinstance (date , dict )
514+ or "date" not in date
515+ or "dateType" not in date
516+ ):
516517 errors .append ("Each 'date' must have 'date' and 'dateType'." )
517518
518519 # Check for 'identifiers'
519520 if "identifiers" not in json_record :
520521 errors .append ("'identifiers' field is missing." )
521- elif not isinstance (json_record ["identifiers" ], list ) or len (json_record ["identifiers" ]) == 0 :
522+ elif (
523+ not isinstance (json_record ["identifiers" ], list )
524+ or len (json_record ["identifiers" ]) == 0
525+ ):
522526 errors .append ("'identifiers' should be a non-empty list." )
523527 else :
524528 for identifier in json_record ["identifiers" ]:
525- if not isinstance (identifier , dict ) or "identifier" not in identifier or "identifierType" not in identifier :
526- errors .append ("Each 'identifier' must have 'identifier' and 'identifierType'." )
529+ if (
530+ not isinstance (identifier , dict )
531+ or "identifier" not in identifier
532+ or "identifierType" not in identifier
533+ ):
534+ errors .append (
535+ "Each 'identifier' must have 'identifier' and 'identifierType'."
536+ )
527537
528538 # Check for 'creators'
529539 if "creators" not in json_record :
530540 errors .append ("'creators' field is missing." )
531- elif not isinstance (json_record ["creators" ], list ) or len (json_record ["creators" ]) == 0 :
541+ elif (
542+ not isinstance (json_record ["creators" ], list )
543+ or len (json_record ["creators" ]) == 0
544+ ):
532545 errors .append ("'creators' should be a non-empty list." )
533546 else :
534547 for creator in json_record ["creators" ]:
@@ -539,7 +552,9 @@ def validate_metadata(json_record):
539552 errors .append ("'affiliation' in 'creators' should be a list." )
540553 for affiliation in creator ["affiliation" ]:
541554 if not isinstance (affiliation , dict ) or "name" not in affiliation :
542- errors .append ("Each 'affiliation' in 'creators' must have a 'name'." )
555+ errors .append (
556+ "Each 'affiliation' in 'creators' must have a 'name'."
557+ )
543558
544559 for rights in json_record ["rightsList" ]:
545560 if not isinstance (rights , dict ) or "rights" not in rights :
@@ -558,11 +573,19 @@ def validate_metadata(json_record):
558573 errors .append ("Each 'geoLocation' must have 'geoLocationPlace'." )
559574 if "geoLocationPoint" in geo_loc :
560575 point = geo_loc ["geoLocationPoint" ]
561- if not isinstance (point , dict ) or "pointLatitude" not in point or "pointLongitude" not in point :
562- errors .append ("'geoLocationPoint' must have 'pointLatitude' and 'pointLongitude'." )
576+ if (
577+ not isinstance (point , dict )
578+ or "pointLatitude" not in point
579+ or "pointLongitude" not in point
580+ ):
581+ errors .append (
582+ "'geoLocationPoint' must have 'pointLatitude' and 'pointLongitude'."
583+ )
563584
564585 # Check for 'formats'
565- if "formats" in json_record and (not isinstance (json_record ["formats" ], list ) or len (json_record ["formats" ]) == 0 ):
586+ if "formats" in json_record and (
587+ not isinstance (json_record ["formats" ], list ) or len (json_record ["formats" ]) == 0
588+ ):
566589 errors .append ("'formats' should be a non-empty list." )
567590
568591 # Check for 'language'
@@ -594,7 +617,9 @@ def validate_metadata(json_record):
594617 else :
595618 if "resourceTypeGeneral" not in json_record ["types" ]:
596619 errors .append ("'types' must have 'resourceTypeGeneral'." )
597- if "resourceType" in json_record ["types" ] and not isinstance (json_record ["types" ]["resourceType" ], str ):
620+ if "resourceType" in json_record ["types" ] and not isinstance (
621+ json_record ["types" ]["resourceType" ], str
622+ ):
598623 errors .append ("'resourceType' should be a string if provided." )
599624 for location in json_record ["geoLocations" ]:
600625 if not isinstance (location , dict ):
0 commit comments