%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/module_utils/facts/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/module_utils/facts/__pycache__/collector.cpython-39.pyc

a

�)g}9�@s�ddlmZmZmZeZddlmZddlZddl	m
mmZ
ddlmZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�d�Zd#d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Z d$d!d"�Z!dS)%�)�absolute_import�division�print_function)�defaultdictN)�timeoutc@seZdZdZdS)�CycleFoundInFactDepsa Indicates there is a cycle in fact collector deps

    If collector-B requires collector-A, and collector-A requires
    collector-B, that is a cycle. In that case, there is no ordering
    that will satisfy B before A and A and before B. That will cause this
    error to be raised.
    N)�__name__�
__module__�__qualname__�__doc__�rr�H/usr/lib/python3.9/site-packages/ansible/module_utils/facts/collector.pyr)src@seZdZdS)�UnresolvedFactDepN�rr	r
rrrr
r4src@seZdZdS)�CollectorNotFoundErrorNrrrrr
r8src@sZeZdZe�ZdZdZe�Zddd�Ze	dd��Z
dd�Zd	d
�Zddd�Z
dd
d�ZdS)�BaseFactCollector�GenericNcCs0|pg|_||_t|jg�|_|j�|j�dS)zzBase class for things that collect facts.

        'collectors' is an optional list of other FactCollectors for composing.N)�
collectors�	namespace�set�nameZfact_ids�update�	_fact_ids)�selfrrrrr
�__init__Cs
zBaseFactCollector.__init__cCs|�dd�|jkr|SdS)N�system)�get�	_platform)�cls�
platform_inforrr
�platform_matchPsz BaseFactCollector.platform_matchcCs|jr|j�|�S|S�N)rZ	transform)rZkey_namerrr
�_transform_nameVsz!BaseFactCollector._transform_namecCs.t|���D]}|�|�}|�|�||<q|S)zKupdate a dicts keys to use new names as transformed by self._transform_name)�list�keysr"�pop)rZ	fact_dictZold_keyZnew_keyrrr
�_transform_dict_keys[s
z&BaseFactCollector._transform_dict_keyscCs"|j||d�}|jr|�|�}|S)N)�module�collected_facts)�collectrr&�rr'r(Z
facts_dictrrr
�collect_with_namespacees
z(BaseFactCollector.collect_with_namespacecCsi}|S)aBdo the fact collection

        'collected_facts' is a object (a dict, likely) that holds all previously
          facts. This is intended to be used if a FactCollector needs to reference
          another fact (for ex, the system arch) and should not be modified (usually).

          Returns a dict of facts.

          rr*rrr
r)ls
zBaseFactCollector.collect)NN)NN)NN)rr	r
rrrr�required_factsr�classmethodr r"r&r+r)rrrr
r<s




rcCsL|pdg}|pt�}|pt�}|p(tt�}t�}t�}dg}|�|�t�}|D]�}	|	}
|
dkrl|�|�qP|
dkr�|�|�qP|
�d�r�|	dd�}	|	dkr�|�|�qP|	dkr�|�||�qPd}nd}|r�|�|�|	t���|�|	�qP|
|v�rtd|	d	�	t
|��f��|�|	�|�|	�qP|�s:|�|�|�||�|S)
aEreturn a set of FactCollector names based on gather_subset spec.

    gather_subset is a spec describing which facts to gather.
    valid_subsets is a frozenset of potential matches for gather_subset ('all', 'network') etc
    minimal_gather_subsets is a frozenset of matches to always use, even for gather_subset='!all'
    �all�min�!�NTFzHBad subset '%s' given to Ansible. gather_subset options allowed: all, %sz, )�	frozensetrr�extendr�
startswithr�add�	TypeError�join�sorted�difference_update)�
valid_subsets�minimal_gather_subset�
gather_subset�aliases_maprZadditional_subsetsZexclude_subsetsZgather_subset_with_minZexplicitly_addedZsubsetZ	subset_idZexcluderrr
�get_collector_nameszsP








�

r>cCs\t�}t�}|D]F}d}|D]8}|�|�}|s0q|j}||vr|�|�|�|j�qq|Sr!)rr rr5)�all_collector_classes�compat_platformsZfound_collectorsZfound_collectors_namesZcompat_platformr Zall_collector_class�primary_namerrr
�find_collectors_for_platform�s

rBcCs^tt�}tt�}|D]@}|j}||�|�|jD] }||�|�||�|�q2q||fSr!)rr#rr�appendrr5)�collectors_for_platformZfact_id_to_collector_mapr=�collector_classrAZfact_idrrr
�build_fact_id_to_collector_map�s
rFcCsJt�}g}|D]6}|�|g�}|D] }||vr"|�|�|�|�q"q|Sr!)rrrCr5)�collector_names�all_fact_subsetsZseen_collector_classes�selected_collector_classes�collector_name�collector_classesrErrr
�select_collector_classes�s
rLcCsLt�}z||}Wnty0td|��Yn0|D]}|�|j�q6|S)NzFact collector "%s" not found)r�KeyErrorrrr,)rJrHr,rKrErrr
�_get_requires_by_collector_namesrNcCs:t�}|D]*}t||�}|D]}||vr|�|�qq
|S)z�Find any collector names that have unresolved requires

    Returns a list of collector names that correspond to collector
    classes whose .requires_facts() are not in collector_names.
    )rrNr5)rGrH�
unresolvedrJr,Z
required_factrrr
�find_unresolved_requiress
rPcCsLt�}g}|D]"}||vr&|�|�q|�|�q|rHtdd�|���|S)Nzunresolved fact dep %s�,)rr5rCrr7)Zunresolved_requiresrH�	new_namesZfailedrOrrr
�resolve_requiressrScCsHtt�}|D]6}t�}||D]}|jD]}|�|�q(q|||<q|Sr!)rrr,r5)rGrH�dep_maprJZcollector_depsZ	collectorZdeprrr
�build_dep_data+s

rUcCsng}|��}|rjd}t|���D]6\}}|D]}||vr,q q,d}||=|�||f�q |std|��q|S)NFTz?Unable to tsort deps, there was a cycle in the graph. sorted=%s)�copyr#�itemsrCr)rTZsorted_listZunsorted_mapZacyclicZnodeZedgesZedgerrr
�tsort6srXcCs@|��}|��}t||�}|t�kr&q<t||�}|�|�q|Sr!)rVrPrrSr)rGrHrOZ	solutionsrRrrr
�_solve_depsLs


rYcCs�|pg}|pt�}|p dt��i}|p*tj}|t_|p:t�}tt�}|ddig}t||�}t	|�\}	}t|	�
��}
t|
||||d�}t||	�}t
||	�}
t|
�}dd�|D�}t||	�}|S)z6return a list of collector classes that match the argsrr)r:r;r<r=rcSsg|]}|d�qS)rr)�.0�xrrr
�
<listcomp>��z8collector_classes_from_gather_subset.<locals>.<listcomp>)r2�platformrrZDEFAULT_GATHER_TIMEOUTZGATHER_TIMEOUTrrrBrFr$r>rYrUrXrL)r?r:r;r<Zgather_timeoutrr=r@rDrHZall_valid_subsetsrGZcomplete_collector_namesrTZordered_depsZordered_collector_namesrIrrr
�$collector_classes_from_gather_subset[s2




�

�r_)NNNNN)NNNNNN)"Z
__future__rrr�typeZ
__metaclass__�collectionsrr^Z"ansible.module_utils.compat.typingZmodule_utils�compat�typing�tZansible.module_utils.factsr�	Exceptionr�
ValueErrorrrMrrr>rBrFrLrNrPrSrUrXrYr_rrrr
�<module>s>>�
O�

Zerion Mini Shell 1.0