Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
plugins
/
inventory
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: toml.cpython-310.pyc
o O�hs% � @ s� d dl mZ dZdZd dlZd dlZd dlmZm Z d dl mZ d dlm Z mZmZ d dlmZmZmZ d d lmZmZ d d lmZmZ d dlmZ d dlmZ d d lmZm Z dZ!zd dl"Z"dZ!W n e#yk Y nw dZ$zd dl%Z%dZ$W n e#y Y nw dZ&zd dl'Z'dZ&W n e#y� zd dl(Z'dZ&W n e#y� Y nw Y nw e� Z)e!r�e*e"d�r�G dd� de"j+�Z,ee"j-e,� d�Z.ndd� Z.e!r�e"j/Z0e"j1Z2ne&r�e'j/Z0e'j2Z2dd� Z3G dd� de�Z4dS )� )�annotationsaP name: toml version_added: "2.8" short_description: Uses a specific TOML file as an inventory source. description: - TOML based inventory format - File MUST have a valid '.toml' file extension notes: - > Requires one of the following python libraries: 'toml', 'tomli', or 'tomllib' a� # fmt: toml # Example 1 [all.vars] has_java = false [web] children = [ "apache", "nginx" ] vars = { http_port = 8080, myvar = 23 } [web.hosts] host1 = {} host2 = { ansible_port = 222 } [apache.hosts] tomcat1 = {} tomcat2 = { myvar = 34 } tomcat3 = { mysecret = "03#pa33w0rd" } [nginx.hosts] jenkins1 = {} [nginx.vars] has_java = true # Example 2 [all.vars] has_java = false [web] children = [ "apache", "nginx" ] [web.vars] http_port = 8080 myvar = 23 [web.hosts.host1] [web.hosts.host2] ansible_port = 222 [apache.hosts.tomcat1] [apache.hosts.tomcat2] myvar = 34 [apache.hosts.tomcat3] mysecret = "03#pa33w0rd" [nginx.hosts.jenkins1] [nginx.vars] has_java = true # Example 3 [ungrouped.hosts] host1 = {} host2 = { ansible_host = "127.0.0.1", ansible_port = 44 } host3 = { ansible_host = "127.0.0.1", ansible_port = 45 } [g1.hosts] host4 = {} [g2.hosts] host4 = {} N)�MutableMapping�MutableSequence)�partial)�AnsibleFileNotFound�AnsibleParserError�AnsibleRuntimeError)�to_bytes� to_native�to_text)�string_types� text_type)�AnsibleSequence�AnsibleUnicode)�BaseFileInventoryPlugin)�Display)�AnsibleUnsafeBytes�AnsibleUnsafeTextFT�TomlEncoderc s e Zd Z� fdd�Z� ZS )�AnsibleTomlEncoderc sV t t| �j|i |�� | j�t| j�t�t| j�t �t | j�t �t| j�t �i� d S �N)�superr �__init__� dump_funcs�updater �get�listr �strr r )�self�args�kwargs�� __class__� �I/usr/local/lib/python3.10/dist-packages/ansible/plugins/inventory/toml.pyr � s �zAnsibleTomlEncoder.__init__)�__name__� __module__�__qualname__r � __classcell__r# r# r! r$ r � s r )�encoderc C s, t r t�t| ��S trt�t| ��S td��)NzTThe python "toml" or "tomli-w" library is required when using the TOML output format)�HAS_TOML�toml�dumps�convert_yaml_objects_to_native� HAS_TOMLIW�tomli_wr )�datar# r# r$ � toml_dumps� s �r1 c C sN t | t�rtdd� | �� D ��S t | t�rdd� | D �S t | t�r%t| �S | S )a� Older versions of the ``toml`` python library, and tomllib, don't have a pluggable way to tell the encoder about custom types, so we need to ensure objects that we pass are native types. Used with: - ``toml<0.10.0`` where ``toml.TomlEncoder`` is missing - ``tomli`` or ``tomllib`` This function recurses an object and ensures we cast any of the types from ``ansible.parsing.yaml.objects`` into their native types, effectively cleansing the data before we hand it over to the toml library. This function doesn't directly check for the types from ``ansible.parsing.yaml.objects`` but instead checks for the types those objects inherit from, to offer more flexibility. c s s � | ]\}}|t |�fV qd S r �r- )�.0�k�vr# r# r$ � <genexpr>� s � z1convert_yaml_objects_to_native.<locals>.<genexpr>c S s g | ]}t |��qS r# r2 )r3 r5 r# r# r$ � <listcomp>� s z2convert_yaml_objects_to_native.<locals>.<listcomp>)� isinstance�dict�itemsr r )�objr# r# r$ r- � s r- c s>