관리-도구
편집 파일: __init__.cpython-39.pyc
a �)g�P � @ s: d dl mZmZmZ eZd dlZd dlZd dlZd dl m Z d dlmZm Z d dlmZ d dlmZ d dlmZ d dlmZ d d lmZmZ d d lmZ d dlmZ d dlm Z d d l!m"Z" d dl#m$Z$m%Z% e"� Z&dd� Zddd�Z'd dd�Z(dd� Z)G dd� de�Z*G dd� de*�Z+G dd� de,�Z-G dd� de,�Z.dS )!� )�absolute_import�division�print_functionN)�Mapping)�AnsibleError�AnsibleParserError)�to_safe_group_name)� parse_address)� AnsiblePlugin)�CachePluginAdjudicator)�to_bytes� to_native)�boolean)�string_types)�Templar)�Display)�combine_vars�load_extra_varsc C s t | ddd�S )NT)�forceZsilent)� original_safe)�name� r �F/usr/lib/python3.9/site-packages/ansible/plugins/inventory/__init__.pyr , s r c C s d| v S )z� A helper function that checks a given host line to see if it contains a range pattern described in the docstring above. Returns True if the given line contains a pattern, else False. �[r )�liner r r �detect_range1 s r c s� g }| �r�| � ddd�� ddd��d�\}}}|�d�}t|�dkrXt|�dkrXtd��|d }|d }t|�dkrzd}n|d }|s�d }|s�td��|d d kr�t|�dkr�t|�� � t|�kr�td��� fd d�} nt} zJtj�|�} tj�|�}| |k�rtd��ttj| |d t |�� �}W n0 t �yV tt |�t |�d t |��}Y n0 |D ]>} d�|| | �|f�}t |��r�|�t|�� n |�|� �q\|S dS )a� A helper function that expands a given line that contains a pattern specified in top docstring, and returns a list that consists of the expanded version. The '[' and ']' characters are used to maintain the pseudo-code appearance. They are replaced in this function with '|' to ease string splitting. References: https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#hosts-and-groups r �|� �]�:� � z.host range must be begin:end or begin:end:stepr �0z!host range must specify end valuez:host range must specify equal-length begin and end formatsc s t | ��� �S �N)�str�zfill)�x�Zrlenr r �filli s z#expand_hostname_range.<locals>.fillz!host range must have begin <= end� N)�replace�split�lenr r$ �string� ascii_letters�index�list�int� ValueError�range�joinr �extend�expand_hostname_range�append)r Z all_hosts�headZnrange�tailZboundsZbeg�end�stepr( Zi_begZi_end�seqZrseqZhnamer r'