
    Vh<                    L    d dl mZ d dlZd dlmZ d dlmZ dZd Zd Z	d Z
d	 Zy)
    )annotationsN)distro)get_all_subclasses)get_distributionget_distribution_versionget_platform_subclassc                     t        j                         j                         } t        j                         dk(  r| dk(  rd} | S | dk(  rd} | S | sd} | S )a  
    Return the name of the distribution the module is running on.

    :rtype: NativeString or None
    :returns: Name of the distribution the module is running on

    This function attempts to determine what distribution the code is running
    on and return a string representing that value. If the platform is Linux
    and the distribution cannot be determined, it returns ``OtherLinux``.
    LinuxAmznAmazonRhelRedhat
OtherLinux)r   id
capitalizeplatformsystem)distributions    T/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/common/sys_info.pyr   r      sc     99;))+LG#6!#L  V##L  'L    c                    d} t        d      }t        j                         } t        j                         }| K||v rEt        j                  d      }|dk(  r#dj	                  |j                  d      dd       } |dk(  r|} | S d	} | S )
a/  
    Get the version of the distribution the code is running on

    :rtype: NativeString or None
    :returns: A string representation of the version of the distribution. If it
    cannot determine the version, it returns an empty string. If this is not run on
    a Linux machine it returns None.
    N)centosdebianT)bestr   .   r    )	frozensetr   versionr   joinsplit)r   needs_best_version	distro_idversion_bests       r   r   r   (   s     G" $ 
 nnG		I**!>>t4L
 I%))L$6$6t$<Ra$@A
 I%&
 N Nr   c                 ^   d} t        j                         dk(  rt        j                         }|j	                  d      } | |j	                  d      } | <t        j
                         dk(  r%t        j                         }|j	                  d      } | t        j                         } | dk(  rd} | S )z
    Return the code name for this Linux Distribution

    :rtype: NativeString or None
    :returns: A string representation of the distribution's codename or None if not a Linux distro
    Nr
   version_codenameubuntu_codenameubuntucodenamer   )r   r   r   os_release_infogetr   lsb_release_infor)   )r)   r*   r,   s      r   get_distribution_codenamer-   Q   s     HG# !002"&&'9:&**+<=H		x 7%668'++J7H(H3Or   c                2   t        j                         }t               }d}|?t        |       D ]1  }|j                  |j                  |k(  s |j                   |k(  s0|}3 |/t        |       D ]!  }|j                   |k(  s|j                   |}# || }|S )ay  
    Finds a subclass implementing desired functionality on the platform the code is running on

    :arg cls: Class to find an appropriate subclass for
    :returns: A class that implements the functionality on this platform

    Some Ansible modules have different implementations depending on the platform they run on.  This
    function is used to select between the various implementations and choose one.  You can look at
    the implementation of the Ansible :ref:`User module<user_module>` module for an example of how to use this.

    This function replaces ``basic.load_platform_subclass()``.  When you port code, you need to
    change the callers to be explicit about instantiating the class.  For instance, code in the
    Ansible User module changed from::

    .. code-block:: python

        # Old
        class User:
            def __new__(cls, args, kwargs):
                return load_platform_subclass(User, args, kwargs)

        # New
        class User:
            def __new__(cls, *args, **kwargs):
                new_cls = get_platform_subclass(User)
                return super(cls, new_cls).__new__(new_cls)
    N)r   r   r   r   r   )clsthis_platformr   subclassscs        r   r   r   o   s    8 OO%M#%LH $S) 	B*r,/NSUS^S^boSo	 $S) 	B{{m+0G	 Or   )
__future__r   r   ansible.module_utilsr   "ansible.module_utils.common._utilsr   __all__r   r   r-   r    r   r   <module>r8      s0   
 #  ' A T0&R<-r   