
    Vh                        d dl mZ d dlZd dlZd dlmc mc mZ d dl	m
Z
 d dl	mZ d dlmZ  G d dej                        Z G d d	ej                        Z	 	 	 	 	 dd
Zy)    )annotationsN)timeout)	collector)	is_stringc                  2     e Zd ZdZd fd	Zd ZddZ xZS )AnsibleFactCollectoram  A FactCollector that returns results under 'ansible_facts' top level key.

       If a namespace if provided, facts will be collected under that namespace.
       For ex, a ansible.module_utils.facts.namespace.PrefixFactNamespace(prefix='ansible_')

       Has a 'from_gather_subset() constructor that populates collectors based on a
       gather_subset specifier.c                >    t         t        |   ||       || _        y )N)
collectors	namespace)superr   __init__filter_spec)selfr
   r   r   	__class__s       \/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/facts/ansible_collector.pyr   zAnsibleFactCollector.__init__2   s(    "D2j=F 	3 	H '    c                P   |r|dk(  r|S t        |      r|g}g }|D ]  }|j                         D ]r  \  }}|rt        j                  ||      r|j                  ||f       2|j	                  d      rDd|z  }t        j                  ||      s`|j                  ||f       t  |S )N*)ansible_facterohaiz
ansible_%s)r   itemsfnmatchappend
startswith)r   
facts_dictr   foundfxygs           r   _filterzAnsibleFactCollector._filter9   s    kS0[!&-K 	-A"((* -1GOOAq1LL!Q(&DE$q(Aq!,aV,-	- r   c                   |xs i }i }| j                   D ]b  }i }	 |j                  ||      }|j                  |j                                |j                  | j                  || j                               d |S # t        $ rQ}t        j                  j                  t        |             t        j                  j                  d       Y d }~d }~ww xY w)N)modulecollected_facts
)r
   collect_with_namespace	Exceptionsysstderrwritereprupdatecopyr"   r   )r   r$   r%   r   collector_obj	info_dictes          r   collectzAnsibleFactCollector.collectM   s    )/R
!__ 	IMI' *@@Q` A b	 ""9>>#34 dll9d6F6FGH#	I&   '

  a)

  &&'s   A<<	CACC)NNNNN)__name__
__module____qualname____doc__r   r"   r2   __classcell__r   s   @r   r   r   )   s    #'(r   r   c                  >     e Zd ZdZdZ e       Zd fd	ZddZ xZ	S )CollectorMetaDataCollectorz@Collector that provides a facts with the gather_subset metadata.gather_subsetc                J    t         t        |   ||       || _        || _        y )N)r   r;   r   r<   module_setup)r   r
   r   r<   r>   r   s        r   r   z#CollectorMetaDataCollector.__init__n   s%    ($8YO*(r   c                X    d| j                   i}| j                  r| j                  |d<   |S )Nr<   r>   r<   r>   )r   r$   r%   
meta_factss       r   r2   z"CollectorMetaDataCollector.collects   s5     &t'9'9:

 )-):):J~&r   )NNNNr3   )
r4   r5   r6   r7   nameset	_fact_idsr   r2   r8   r9   s   @r   r;   r;   h   s    JDI)

r   r;   c                4   |xs g }|xs dg}|xs t         j                  }|xs
 t               }t        j                  | |||      }g }|D ]  } ||      }	|j                  |	        t        |d      }
|j                  |
       t        |||      }|S )Nall)all_collector_classesminimal_gather_subsetr<   gather_timeout)r   Tr@   )r
   r   r   )r   DEFAULT_GATHER_TIMEOUT	frozensetr   $collector_classes_from_gather_subsetr   r;   r   )rG   r   r   r<   rI   rH   collector_classesr
   collector_classr/   collector_meta_data_collectorfact_collectors               r   get_ansible_collectorrQ      s     #K!,eWM#Ew'E'EN1@Y[ 	66"7"7')		+  J, )')<-() 	#04	6 " 34 	
)4'0	2 
 r   )NNNNN)
__future__r   r   r)   "ansible.module_utils.compat.typingmodule_utilscompattypingtansible.module_utils.factsr   r   'ansible.module_utils.common.collectionsr   BaseFactCollectorr   r;   rQ    r   r   <module>r\      sZ   : #  
 . . . 0 =<966 <~!<!< 2 %)&*(,)-04#r   