관리-도구
편집 파일: sys_info.cpython-39.pyc
a �)go � @ s` d dl mZmZmZ eZd dlZd dlmZ d dl m Z dZdd� Zdd � Z d d� Zdd � ZdS )� )�absolute_import�division�print_functionN)�distro)�get_all_subclasses)�get_distribution�get_distribution_version�get_platform_subclassc C s@ t �� �� } t�� dkr<| dkr&d} n| dkr4d} n| 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``. �LinuxZAmznZAmazonZRhelZRedhatZ OtherLinux)r �id� capitalize�platform�system)�distribution� r �H/usr/lib/python3.9/site-packages/ansible/module_utils/common/sys_info.pyr s r c C sn d} t d�}t�� } t�� }| durf||v rjtjdd�}|dkrXd�|�d�dd� �} |dkrj|} nd } | 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)Zbestr �.� r � )� frozensetr �versionr �join�split)r Zneeds_best_versionZ distro_idZversion_bestr r r r ) s r c C sz d} t �� dkrvt�� }|�d�} | du r4|�d�} | du rZt�� dkrZt�� }|�d�} | du rvt�� } | dkrvd} | 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 Zversion_codenameZubuntu_codenameZubuntu�codenamer )r r r �os_release_info�getr �lsb_release_infor )r r r r r r �get_distribution_codenameR s r c C s� t �� }t� }d}|durJt| �D ]&}|jdur"|j|kr"|j |kr"|}q"|du rxt| �D ]}|j |krZ|jdu rZ|}qZ|du r�| }|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 )�clsZ this_platformr �subclassZscr r r r p s r )Z __future__r r r �typeZ __metaclass__r Zansible.module_utilsr Z"ansible.module_utils.common._utilsr �__all__r r r r r r r r �<module> s )