관리-도구
편집 파일: validation.cpython-39.opt-1.pyc
a �)g�J � @ sJ d dl mZmZmZ eZd dlZd dlZd dlm Z d dl mZ d dlm Z d dlmZ d dlmZ d dlmZ d d lmZ d d lmZmZmZmZ dd� Zd6dd�Zd7dd�Zd8dd�Zd9dd�Zd:dd�Z d;dd�Z!d<dd�Z"d=dd�Z#d>d d!�Z$d"d#� Z%d$d%� Z&d&d'� Z'd(d)� Z(d*d+� Z)d,d-� Z*d.d/� Z+d0d1� Z,d2d3� Z-d4d5� Z.dS )?� )�absolute_import�division�print_functionN)�literal_eval)� to_native)�json)�is_iterable)�jsonify)�human_to_bytes)�boolean)�binary_type� integer_types�string_types� text_typec C s t | �s| g} tt| ��|��S )a Count the number of occurrences of a key in a given dictionary :arg terms: String or iterable of values to check :arg parameters: Dictionary of parameters :returns: An integer that is the number of occurrences of the terms values in the provided dictionary. )r �len�set�intersection)�terms� parameters� r �J/usr/lib/python3.9/site-packages/ansible/module_utils/common/validation.py�count_terms s r Fc C s� t | t�s|r| d fS | S t�d| �r6|r2| d fS | S t�d| �rR|rN| d fS | S z t| �}|rj|d fW S |W S W n@ ty� } z(|r�| |fW Y d }~S | W Y d }~S d }~0 0 d S )Nz \w\.\w+\(z import \w+)� isinstancer �re�searchr � Exception)�value�locals�include_exceptions�result�er r r � safe_eval* s* r! c C s| g }| du r|S | D ] }t ||�}|dkr|�|� q|rxdd� |D �}dd�|� }|rld�|d�|��}tt|���|S ) a� Check mutually exclusive terms against argument parameters Accepts a single list or list of lists that are groups of terms that should be mutually exclusive with one another :arg terms: List of mutually exclusive parameters :arg parameters: Dictionary of parameters :kwarg options_context: List of strings of parent key names if ``terms`` are in a sub spec. :returns: Empty list or raises :class:`TypeError` if the check fails. N� c S s g | ]}d � |��qS )�|)�join)�.0�checkr r r � <listcomp>^ � z,check_mutually_exclusive.<locals>.<listcomp>z%parameters are mutually exclusive: %s�, �{0} found in {1}� -> �r �appendr$ �format� TypeErrorr )r r �options_context�resultsr&