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)ÚOnlyOnez'Check Properties Resource ConfigurationZE2523z;Check Properties that need only one of a list of propertiesz&Making sure CloudFormation properties z,that require only one property from a list. zOne has to be specified.z5https://github.com/aws-cloudformation/cfn-python-lintÚ resourcescsjtt|ƒjƒtjjdƒ}|d|_|d|_x|jD]}|jj |ƒq6Wx|jD]}|j j |ƒqRWdS)ZInitz!data/AdditionalSpecs/OnlyOne.jsonZ ResourceTypesZ PropertyTypesN) ÚsuperrÚ__init__ÚcfnlintZhelpersZload_resourcesÚresource_types_specsÚproperty_types_specsZresource_property_typesÚappendZresource_sub_property_types)ÚselfZ onlyonespecZresource_type_specZproperty_type_spec)Ú __class__©ú„/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/properties/OnlyOne.pyr s     zOnlyOne.__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éZScenarioNz-Only one of [{0}] should be specified for {1}z, ú/z and cSsg|]\}}d||f‘qS)zwhen condition "%s" is %sr)Ú.0ÚkÚvrrrú >sz!OnlyOne.check..z0Only one of [{0}] should be specified {1} at {2})Zget_object_without_conditionsr rÚformatÚjoinÚmapÚstrÚitems) r Ú propertiesÚ onlyonepropsÚpathÚcfnÚmatchesZ property_setsZ property_setZ onlyonepropÚcountÚpropÚmessageZ scenario_textrrrÚcheck+s(       *2z OnlyOne.checkcCs,g}|jj|iƒ}|j|j||||ƒƒ|S)zMatch for sub properties)r ÚgetÚextendr#)r rZ property_typerrrrrrrÚmatch_resource_sub_propertiesGsz%OnlyOne.match_resource_sub_propertiescCs,g}|jj|iƒ}|j|j||||ƒƒ|S)zCheck CloudFormation Properties)r r$r%r#)r rZ resource_typerrrrrrrÚmatch_resource_propertiesPsz!OnlyOne.match_resource_propertieszRMaking sure CloudFormation properties that require only one property from a list. zjMaking sure CloudFormation properties that require only one property from a list. One has to be specified.)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚidZ shortdescÚ descriptionZ source_urlÚtagsrr#r&r'Ú __classcell__rr)r rrs  r)r+rrrZcfnlint.helpersrrrrrÚs