
    Vh                    V    d Z ddlmZ ddlZddlmZmZmZmZ ddl	m
Z
  G d d	e      Zy)
(Layout provider for Ansible collections.    )annotationsN   )ContentLayoutLayoutProviderCollectionDetailLayoutMessages   )is_valid_identifierc                  `    e Zd ZdZedd       Zd	dZed
d       Zedd       Zed
d       Z	y)CollectionLayoutr   c                    t         j                  j                  t         j                  j                  t         j                  j                  |                   dk(  ryy)zBReturn True if the given path is a content root for this provider.ansible_collectionsTF)ospathbasenamedirname)r   s    a/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/provider/layout/collection.pyis_content_rootz CollectionLayout.is_content_root   s<     77BGGOOBGGOOD,ABCG\\    c                   t        d | j                  D              }t        j                  j	                  t        j                  j	                  |            }t        j                  j                  ||      }|j                  t        j                  j                        \  }}t        j                  j	                  |      }t               }t               }	t               }
| j                  ||       | j                  ||	       | j                  ||
       | j                  ||	      }| j                  ||
       g }t        |      s|j                  d| d       t        |      s|j                  d| d       t        ||f|t        |||      ddd|d	|j!                  t        j                  j                        d
|	ddd|
|dS )z/Create a Layout using the given root and paths.c              3  `   K   | ]&  }|t         j                  j                  d |      f ( yw)pluginsN)r   r   join).0ps     r   	<genexpr>z*CollectionLayout.create.<locals>.<genexpr>   s$     WQY :;Ws   ,.zThe namespace "z1" is an invalid identifier or a reserved keyword.z
The name ")name	namespaceroottestsztests/outputztests/sanityztests/integrationz(tests/integration/integration_config.ymlz
tests/unitztests/unit/plugins/modulesztests/unit/plugins/module_utils)plugin_paths
collection	test_pathresults_pathsanity_pathsanity_messagesintegration_pathintegration_targets_pathintegration_vars_pathintegration_messages	unit_pathunit_module_pathunit_module_utils_pathunit_messagesunsupported)dictPLUGIN_TYPESr   r   r   relpathsplitsepr	   "_CollectionLayout__check_test_path)_CollectionLayout__check_integration_path"_CollectionLayout__check_unit_pathr   appendr   r   rstrip)selfr    pathsr"   collection_rootcollection_dircollection_namespacecollection_namer'   r+   r/   r)   errorss                r   createzCollectionLayout.create   s   WTEVEVWW''//"''//$*?@?
 1?0D0DRWW[[0Q-o''///:(*-/&( 	uo6u&:;um4 $(#@#@H\#] um4"#78MMO,@+AArst"?3MMJ&77hij
 &'$.$
 '&+0%=%D%DRWW[[%Q"L!5"9#D'+
 	
r   c                    dt        fd| D              }dt        fd| D              }|r%|r#|j                  j                  ddd       y |r#|j                  j                  ddd       y y )	Nztests/c              3  @   K   | ]  }|j                          y wN
startswith)r   r   modern_test_paths     r   r   z5CollectionLayout.__check_test_path.<locals>.<genexpr>[        $Y4T__5E%F$Y   ztest/c              3  @   K   | ]  }|j                          y wrE   rF   )r   r   legacy_test_paths     r   r   z5CollectionLayout.__check_test_path.<locals>.<genexpr>]   rI   rJ   Ignoring tests in "" in favor of "".z" that should be in ")anywarningr9   )r<   messagesmodern_test_path_foundlegacy_test_path_foundrL   rH   s       @@r   __check_test_pathz"CollectionLayout.__check_test_pathX   sw    #!$$YSX$Y!Y"!$$YSX$Y!Y!&<##Rbdt$uv###Xhjz${| $r   c                   dt        fd| D              }dt        fd| D              }|r(|r&|j                  j                  ddd       }|S |r&|j                  j                  dd	d
       }|S |r"|j                  j                  dz         }|S |j                  j                  ddd       }|S )Nzroles/test/c              3  @   K   | ]  }|j                          y wrE   rF   )r   r   modern_integration_paths     r   r   z<CollectionLayout.__check_integration_path.<locals>.<genexpr>g        +gY]DOO<S,T+grJ   ztests/integration/targets/c              3  @   K   | ]  }|j                          y wrE   rF   )r   r   legacy_integration_paths     r   r   z<CollectionLayout.__check_integration_path.<locals>.<genexpr>i   rY   rJ   rM   rN   rO   zFalling back to tests in "z" because "z" was not found.zLoading tests from "%s".z&Cannot run integration tests without "z" or ")rP   rQ   r9   infoerror)r<   rR   modern_integration_path_foundlegacy_integration_path_foundr)   r[   rX   s        @@r   __check_integration_pathz)CollectionLayout.__check_integration_pathd   s    "/(++gaf+g(g%">(++gaf+g(g%(-J##Ri  lC  %D  E'>$ (' +MM  `w  zQ  "R  S'>$ (' +MM  !;>U!UV'>$
 (' NN!!Zq  tK  #L  M'>$''r   c                :   dt        fd| D              }dt        fd| D              }|r%|r#|j                  j                  ddd       y |r#|j                  j                  dd	d
       y |ry |j                  j                  dz         y )Nztests/unit/c              3  @   K   | ]  }|j                          y wrE   rF   )r   r   modern_unit_paths     r   r   z5CollectionLayout.__check_unit_path.<locals>.<genexpr>}   rI   rJ   ztests/units/c              3  @   K   | ]  }|j                          y wrE   rF   )r   r   legacy_unit_paths     r   r   z5CollectionLayout.__check_unit_path.<locals>.<genexpr>   rI   rJ   rM   rN   rO   zRename "z" to "z" to run unit tests.z#Cannot run unit tests without "%s".)rP   rQ   r9   r]   )r<   rR   modern_unit_path_foundlegacy_unit_path_foundre   rc   s       @@r   __check_unit_pathz"CollectionLayout.__check_unit_pathz   s    (!$$YSX$Y!Y)!$$YSX$Y!Y!&<##Rbdt$uv###P`br$st#NN!!"GJZ"Z[r   N)r   strreturnbool)r    ri   r<   	list[str]rj   r   )r<   rl   rR   r	   rj   None)r<   rl   rR   r	   rj   ri   )
__name__
__module____qualname____doc__staticmethodr   rB   r6   r7   r8    r   r   r   r      s]    2 9
v 	} 	} ( (* \ \r   r   )rq   
__future__r   r    r   r   r   r	   utilr   r   rs   r   r   <module>rw      s-    . " 	 
v\~ v\r   