I have the following working, where applename and appletype are always provided.
Stage_Bucket = 'stage-bucket'
for zip_obj in s3.Bucket(Stage_Bucket).objects.all():
key = zip_obj.key
copy_source = {'Bucket': Stage_Bucket, 'Key': key}
metadata = s3.meta.client.head_object(Bucket=Stage_Bucket,Key=key)
Study_Name = metadata['Metadata']['applename']
Study_Type = metadata['Metadata']['appletype']
However I want to perform an if/else statement based on a sometimes available metadata field, which we can call applecolour. i.e. sometimes it's there, sometimes it's not.
How can I check if the metadata is there/not (has a provided value), and therefore act whether it is empty or not?