def _notification_config_from_xml(self, xml):
    parsed_xml = xmltodict.parse(xml)
    if (not len(parsed_xml['NotificationConfiguration'])):
        return {}
    notification_fields = [('Topic', 'sns'), ('Queue', 'sqs'), ('CloudFunction', 'lambda')]
    event_names = ['s3:ReducedRedundancyLostObject', 's3:ObjectCreated:*', 's3:ObjectCreated:Put', 's3:ObjectCreated:Post', 's3:ObjectCreated:Copy', 's3:ObjectCreated:CompleteMultipartUpload', 's3:ObjectRemoved:*', 's3:ObjectRemoved:Delete', 's3:ObjectRemoved:DeleteMarkerCreated']
    found_notifications = 0
    for (name, arn_string) in notification_fields:
        the_notification = parsed_xml['NotificationConfiguration'].get('{}Configuration'.format(name))
        if the_notification:
            found_notifications += 1
            if (not isinstance(the_notification, list)):
                the_notification = parsed_xml['NotificationConfiguration']['{}Configuration'.format(name)] = [the_notification]
            for n in the_notification:
                if (not n[name].startswith('arn:aws:{}:'.format(arn_string))):
                    raise InvalidNotificationARN()
                assert n['Event']
                if (not isinstance(n['Event'], list)):
                    n['Event'] = [n['Event']]
                for event in n['Event']:
                    if (event not in event_names):
                        raise InvalidNotificationEvent()
                if n.get('Filter'):
                    if (not n['Filter']['S3Key']):
                        raise KeyError()
                    if (not isinstance(n['Filter']['S3Key']['FilterRule'], list)):
                        n['Filter']['S3Key']['FilterRule'] = [n['Filter']['S3Key']['FilterRule']]
                    for filter_rule in n['Filter']['S3Key']['FilterRule']:
                        assert (filter_rule['Name'] in ['suffix', 'prefix'])
                        assert filter_rule['Value']
    if (not found_notifications):
        return {}
    return parsed_xml['NotificationConfiguration']
def _notification_config_from_xml(self, xml):
    parsed_xml = xmltodict.parse(xml)
    if (not len(parsed_xml['NotificationConfiguration'])):
        return {}
    notification_fields = [('Topic', 'sns'), ('Queue', 'sqs'), ('CloudFunction', 'lambda')]
    event_names = ['s3:ReducedRedundancyLostObject', 's3:ObjectCreated:*', 's3:ObjectCreated:Put', 's3:ObjectCreated:Post', 's3:ObjectCreated:Copy', 's3:ObjectCreated:CompleteMultipartUpload', 's3:ObjectRemoved:*', 's3:ObjectRemoved:Delete', 's3:ObjectRemoved:DeleteMarkerCreated']
    found_notifications = 0
    for (name, arn_string) in notification_fields:
        the_notification = parsed_xml['NotificationConfiguration'].get('{}Configuration'.format(name))
        if the_notification:
            found_notifications += 1
            if (not isinstance(the_notification, list)):
                the_notification = parsed_xml['NotificationConfiguration']['{}Configuration'.format(name)] = [the_notification]
            for n in the_notification:
                if (not n[name].startswith('arn:aws:{}:'.format(arn_string))):
                    raise InvalidNotificationARN()
                assert n['Event']
                if (not isinstance(n['Event'], list)):
                    n['Event'] = [n['Event']]
                for event in n['Event']:
                    if (event not in event_names):
                        raise InvalidNotificationEvent()
                if n.get('Filter'):
                    if (not n['Filter']['S3Key']):
                        raise KeyError()
                    if (not isinstance(n['Filter']['S3Key']['FilterRule'], list)):
                        n['Filter']['S3Key']['FilterRule'] = [n['Filter']['S3Key']['FilterRule']]
                    for filter_rule in n['Filter']['S3Key']['FilterRule']:
                        assert (filter_rule['Name'] in ['suffix', 'prefix'])
                        assert filter_rule['Value']
    if (not found_notifications):
        return {}
    return parsed_xml['NotificationConfiguration']