3 Dã\‹ ã@s0dZddlmZddlmZGdd„deƒZdS)aº Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. é)ÚCloudFormationLintRule)Ú RuleMatchc@sPeZdZdZdZdZdZdZddgZdd „Z d d „Z d d „Z dd„Z dd„Z dS)ÚEventsLogGroupNamezMCheck if the settings of multiple subscriptions are included for one LogGroupZE2529z!Check for duplicate Lambda eventszPCheck if there are any duplicate log groups in the Lambda event trigger element.zvhttps://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#user-content-cloudwatchlogsÚ resourcesÚlambdacCs4g}d}|j|ƒ}|j|ƒr0|jtd|jƒƒƒ|S)z1Check if Lambda Events Subscription is duplicatedzZYou must specify the AWS::Serverless::Function event correctly. LogGroups are duplicated. Úpath)Ú,_EventsLogGroupName__get_log_group_name_listÚ"_EventsLogGroupName__is_duplicatedÚappendrÚformat)ÚselfÚcfnÚmatchesÚmessageÚlog_group_name_list©rú‰/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/lmbd/EventsLogGroupName.pyÚ$check_events_subscription_duplicateds  z7EventsLogGroupName.check_events_subscription_duplicatedcCs|j|ƒ}t|ƒt|ƒkS)N)Ú_EventsLogGroupName__removeÚlen)r Zduplicate_listZ unique_listrrrZ__is_duplicated,s z"EventsLogGroupName.__is_duplicatedcCs(g}x|D]}||kr |j|ƒq W|S)N)r )r Z duplicateZ final_listZelerrrZ__remove0s  zEventsLogGroupName.__removecCs>g}x4|jdƒjƒD]"}|djdƒ}|j|jdƒƒqW|S)NzAWS::Logs::SubscriptionFilteréZ PropertiesZ LogGroupName)Ú get_resourcesÚitemsÚgetr )r r rÚvalueÚproprrrZ__get_log_group_name_list7s z,EventsLogGroupName.__get_log_group_name_listcCsg}|j|j|ƒƒ|S)z1Check if Lambda Events Subscription is duplicated)Úextendr)r r rrrrÚmatch>s zEventsLogGroupName.matchN)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚidZ shortdescÚ descriptionZ source_urlÚtagsrr rrrrrrrrsrN)r!ZcfnlintrrrrrrrÚs