3 Dã\ã@s8dZddlmZddlmZddlZGdd„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)Ú RuleMatchNcsNeZdZdZdZdZdZdZdgZ‡fd d „Z d d „Z d d„Z dd„Z ‡Z S)Ú AtLeastOnez'Check Properties Resource ConfigurationZE2522z?Check Properties that need at least one of a list of propertiesz&Making sure CloudFormation properties z0that require at least one property from a list. zMore than one can be included.z5https://github.com/aws-cloudformation/cfn-python-lintÚ resourcescsjtt|ƒjƒtjjdƒ}|d|_|d|_x|jD]}|jj |ƒq6Wx|jD]}|j j |ƒqRWdS)ZInitz$data/AdditionalSpecs/AtLeastOne.jsonZ ResourceTypesZ PropertyTypesN) ÚsuperrÚ__init__ÚcfnlintZhelpersZload_resourcesÚresource_types_specsÚproperty_types_specsZresource_property_typesÚappendZresource_sub_property_types)ÚselfZatleastonespecZresource_type_specZproperty_type_spec)Ú __class__©ú‡/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/properties/AtLeastOne.pyr s     zAtLeastOne.__init__c Csðg}|j|ƒ}xÜ|D]Ô}xÎ|D]Æ}d} x |D]} | |dkr,| d7} q,W| dkr|ddkr’d} |jt|| jdjtt|ƒƒdjtt|ƒƒƒƒƒqd jd d „|djƒDƒƒ} d } |jt|| jdjtt|ƒƒ| djtt|ƒƒƒƒƒqWqW|S) z Check itselfrZObjectéZScenarioNz1At least one of [{0}] should be specified for {1}z, ú/z and cSsg|]\}}d||f‘qS)zwhen condition "%s" is %sr)Ú.0ÚkÚvrrrú >sz$AtLeastOne.check..z4At least one of [{0}] should be specified {1} at {2})Zget_object_without_conditionsr rÚformatÚjoinÚmapÚstrÚitems) r Ú propertiesÚatleastonepropsÚpathÚcfnÚmatchesZ property_setsZ property_setZatleastonepropÚcountÚpropÚmessageZ scenario_textrrrÚcheck+s(       *2zAtLeastOne.checkcCs,g}|jj|iƒ}|j|j||||ƒƒ|S)zMatch for sub properties)r ÚgetÚextendr#)r rZ property_typerrrrrrrÚmatch_resource_sub_propertiesGsz(AtLeastOne.match_resource_sub_propertiescCs,g}|jj|iƒ}|j|j||||ƒƒ|S)zCheck CloudFormation Properties)r r$r%r#)r rZ resource_typerrrrrrrÚmatch_resource_propertiesPsz$AtLeastOne.match_resource_propertieszVMaking sure CloudFormation properties that require at least one property from a list. ztMaking sure CloudFormation properties that require at least one property from a list. More than one can be included.)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚidZ shortdescÚ descriptionZ source_urlÚtagsrr#r&r'Ú __classcell__rr)r rrs  r)r+rrrZcfnlint.helpersrrrrrÚs