3 D\ @s8dZddlZddlmZddlmZGdddeZdS)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. N)CloudFormationLintRule) RuleMatchc@s.eZdZdZdZdZdZdZdgZddZ d S) Existsz%Check if used Conditions are defined ZE8002z.Check if the referenced Conditions are definedzNMaking sure the used conditions are actually defined in the Conditions sectionz`https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html conditionscCsjg}i}|jjdi}|jd}x8|D]0}t|d trJ|||d d<q&|||d <q&Wx6|jjD]&\}}d|krhd|dg} | ||d<qhW|jd} xH| D]@} | ddkrt| d ttj tj frd| d g} | || d<qWxB|jjdijD],\} } d| krd| dg} | || d<qWx:|jD].\}}||kr4d}|j t ||j |q4W|S)zCheck CloudFormation ConditionsZ ConditionszFn::Ifr ConditionZ ResourcesZOutputszCondition {0} is not defined.rrrrr)templategetZsearch_deep_keys isinstancelist get_resourcesitemsstrsix text_type string_typesappendrformat)selfZcfnmatchesZref_conditionsrZiftreesZiftree resource_nameZresource_valuespathZ condtreesZcondtree_Z output_valuesZ ref_conditionZref_pathmessagery/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/conditions/Exists.pymatchs:          z Exists.matchN) __name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrrrrrrsr)r!rZcfnlintrrrrrrrs