Your IP : 18.226.187.232


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/__pycache__/distro.cpython-311.pyc

�

]�Dg���X�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	dZ
	ej�d
d��Zej�dd
��ZdZddiZdddddd�Z ddiZ!ej"d��Z#ej"d��Z$dddedddfZ%d7d�Z&d�Z'd8d�Z(d9d �Z)d8d!�Z*d8d"�Z+d8d#�Z,d8d$�Z-d%�Z.d&�Z/d9d'�Z0d(�Z1d)�Z2d*�Z3d+�Z4d,�Z5d-�Z6d.�Z7d/�Z8	dd0l9m:Z:n#e;$rGd1�d2e<��Z:YnwxYwGd3�d4e<��Z=e=��Z>d5�Z?e@d6kre?��dSdS):a�
The ``distro`` package (``distro`` stands for Linux Distribution) provides
information about the Linux distribution it runs on, such as a reliable
machine-readable distro ID, or version information.

It is the recommended replacement for Python's original
:py:func:`platform.linux_distribution` function, but it provides much more
functionality. An alternative implementation became necessary because Python
3.5 deprecated this function, and Python 3.8 removed it altogether. Its
predecessor function :py:func:`platform.dist` was already deprecated since
Python 2.6 and removed in Python 3.8. Still, there are many cases in which
access to OS distribution information is needed. See `Python issue 1322
<https://bugs.python.org/issue1322>`_ for more information.
�Nz1.6.0F)�Any�Callable�Dict�Iterable�Optional�Sequence�TextIO�Tuple�Type�	TypedDict�Union�VersionDict��major�minor�build_number�InfoDict��id�version�
version_parts�like�codename�UNIXCONFDIRz/etc�
UNIXUSRLIBDIRz/usr/libz
os-release�ol�oracle�rhel)�enterpriseenterpriseas�enterpriseenterpriseserver�redhatenterpriseworkstation�redhatenterpriseserver�redhatenterprisecomputenode�redhatzA(?:[^)]*\)(.*)\()? *(?:STL )?([\d.+\-a-z]*\d) *(?:esaeler *)?(.+)z(\w+)[-_](release|version)$�debian_versionzlsb-releasezoem-releasezsystem-releasez
plesk-releaseziredmail-releaseTc�n�tjdtd���t�|��S)aG
    .. deprecated:: 1.6.0

        :func:`distro.linux_distribution()` is deprecated. It should only be
        used as a compatibility shim with Python's
        :py:func:`platform.linux_distribution()`. Please use :func:`distro.id`,
        :func:`distro.version` and :func:`distro.name` instead.

    Return information about the current OS distribution as a tuple
    ``(id_name, version, codename)`` with items as follows:

    * ``id_name``:  If *full_distribution_name* is false, the result of
      :func:`distro.id`. Otherwise, the result of :func:`distro.name`.

    * ``version``:  The result of :func:`distro.version`.

    * ``codename``:  The result of :func:`distro.codename`.

    The interface of this function is compatible with the original
    :py:func:`platform.linux_distribution` function, supporting a subset of
    its parameters.

    The data it returns may not exactly be the same, because it uses more data
    sources than the original function, and that may lead to different data if
    the OS distribution is not consistent across multiple data sources it
    provides (there are indeed such distributions ...).

    Another reason for differences is the fact that the :func:`distro.id`
    method normalizes the distro ID string to a reliable machine-readable value
    for a number of popular OS distributions.
    z�distro.linux_distribution() is deprecated. It should only be used as a compatibility shim with Python's platform.linux_distribution(). Please use distro.id(), distro.version() and distro.name() instead.�)�
stacklevel)�warnings�warn�DeprecationWarning�_distro�linux_distribution)�full_distribution_names �=/opt/imunify360/venv/lib64/python3.11/site-packages/distro.pyr-r-�sC��B
�M�	C�	�������%�%�&<�=�=�=�c�4�t���S)aD
    Return the distro ID of the current distribution, as a
    machine-readable string.

    For a number of OS distributions, the returned distro ID value is
    *reliable*, in the sense that it is documented and that it does not change
    across releases of the distribution.

    This package maintains the following reliable distro ID values:

    ==============  =========================================
    Distro ID       Distribution
    ==============  =========================================
    "ubuntu"        Ubuntu
    "debian"        Debian
    "rhel"          RedHat Enterprise Linux
    "centos"        CentOS
    "fedora"        Fedora
    "sles"          SUSE Linux Enterprise Server
    "opensuse"      openSUSE
    "amazon"        Amazon Linux
    "arch"          Arch Linux
    "cloudlinux"    CloudLinux OS
    "exherbo"       Exherbo Linux
    "gentoo"        GenToo Linux
    "ibm_powerkvm"  IBM PowerKVM
    "kvmibm"        KVM for IBM z Systems
    "linuxmint"     Linux Mint
    "mageia"        Mageia
    "mandriva"      Mandriva Linux
    "parallels"     Parallels
    "pidora"        Pidora
    "raspbian"      Raspbian
    "oracle"        Oracle Linux (and Oracle Enterprise Linux)
    "scientific"    Scientific Linux
    "slackware"     Slackware
    "xenserver"     XenServer
    "openbsd"       OpenBSD
    "netbsd"        NetBSD
    "freebsd"       FreeBSD
    "midnightbsd"   MidnightBSD
    ==============  =========================================

    If you have a need to get distros for reliable IDs added into this set,
    or if you find that the :func:`distro.id` function returns a different
    distro ID for one of the listed distros, please create an issue in the
    `distro issue tracker`_.

    **Lookup hierarchy and transformations:**

    First, the ID is obtained from the following sources, in the specified
    order. The first available and non-empty value is used:

    * the value of the "ID" attribute of the os-release file,

    * the value of the "Distributor ID" attribute returned by the lsb_release
      command,

    * the first part of the file name of the distro release file,

    The so determined ID value then passes the following transformations,
    before it is returned by this method:

    * it is translated to lower case,

    * blanks (which should not be there anyway) are translated to underscores,

    * a normalization of the ID is performed, based upon
      `normalization tables`_. The purpose of this normalization is to ensure
      that the ID is as reliable as possible, even across incompatible changes
      in the OS distributions. A common reason for an incompatible change is
      the addition of an os-release file, or the addition of the lsb_release
      command, with ID values that differ from what was previously determined
      from the distro release file name.
    )r,r�r0r/rr�s��Z�:�:�<�<�r0c�6�t�|��S)ak
    Return the name of the current OS distribution, as a human-readable
    string.

    If *pretty* is false, the name is returned without version or codename.
    (e.g. "CentOS Linux")

    If *pretty* is true, the version and codename are appended.
    (e.g. "CentOS Linux 7.1.1503 (Core)")

    **Lookup hierarchy:**

    The name is obtained from the following sources, in the specified order.
    The first available and non-empty value is used:

    * If *pretty* is false:

      - the value of the "NAME" attribute of the os-release file,

      - the value of the "Distributor ID" attribute returned by the lsb_release
        command,

      - the value of the "<name>" field of the distro release file.

    * If *pretty* is true:

      - the value of the "PRETTY_NAME" attribute of the os-release file,

      - the value of the "Description" attribute returned by the lsb_release
        command,

      - the value of the "<name>" field of the distro release file, appended
        with the value of the pretty version ("<version_id>" and "<codename>"
        fields) of the distro release file, if available.
    )r,�name��prettys r/r4r4s��J�<�<����r0c�8�t�||��S)av
    Return the version of the current OS distribution, as a human-readable
    string.

    If *pretty* is false, the version is returned without codename (e.g.
    "7.0").

    If *pretty* is true, the codename in parenthesis is appended, if the
    codename is non-empty (e.g. "7.0 (Maipo)").

    Some distributions provide version numbers with different precisions in
    the different sources of distribution information. Examining the different
    sources in a fixed priority order does not always yield the most precise
    version (e.g. for Debian 8.2, or CentOS 7.1).

    The *best* parameter can be used to control the approach for the returned
    version:

    If *best* is false, the first non-empty version number in priority order of
    the examined sources is returned.

    If *best* is true, the most precise version number out of all examined
    sources is returned.

    **Lookup hierarchy:**

    In all cases, the version number is obtained from the following sources.
    If *best* is false, this order represents the priority order:

    * the value of the "VERSION_ID" attribute of the os-release file,
    * the value of the "Release" attribute returned by the lsb_release
      command,
    * the version number parsed from the "<version_id>" field of the first line
      of the distro release file,
    * the version number parsed from the "PRETTY_NAME" attribute of the
      os-release file, if it follows the format of the distro release files.
    * the version number parsed from the "Description" attribute returned by
      the lsb_release command, if it follows the format of the distro release
      files.
    )r,r�r6�bests  r/rr+s��T�?�?�6�4�(�(�(r0c�6�t�|��S)a�
    Return the version of the current OS distribution as a tuple
    ``(major, minor, build_number)`` with items as follows:

    * ``major``:  The result of :func:`distro.major_version`.

    * ``minor``:  The result of :func:`distro.minor_version`.

    * ``build_number``:  The result of :func:`distro.build_number`.

    For a description of the *best* parameter, see the :func:`distro.version`
    method.
    )r,r�r9s r/rrXs��� � ��&�&�&r0c�6�t�|��S)a5
    Return the major version of the current OS distribution, as a string,
    if provided.
    Otherwise, the empty string is returned. The major version is the first
    part of the dot-separated version string.

    For a description of the *best* parameter, see the :func:`distro.version`
    method.
    )r,�
major_versionr;s r/r=r=j���� � ��&�&�&r0c�6�t�|��S)a6
    Return the minor version of the current OS distribution, as a string,
    if provided.
    Otherwise, the empty string is returned. The minor version is the second
    part of the dot-separated version string.

    For a description of the *best* parameter, see the :func:`distro.version`
    method.
    )r,�
minor_versionr;s r/r@r@xr>r0c�6�t�|��S)a3
    Return the build number of the current OS distribution, as a string,
    if provided.
    Otherwise, the empty string is returned. The build number is the third part
    of the dot-separated version string.

    For a description of the *best* parameter, see the :func:`distro.version`
    method.
    )r,rr;s r/rr�s������%�%�%r0c�4�t���S)a
    Return a space-separated list of distro IDs of distributions that are
    closely related to the current OS distribution in regards to packaging
    and programming interfaces, for example distributions the current
    distribution is a derivative from.

    **Lookup hierarchy:**

    This information item is only provided by the os-release file.
    For details, see the description of the "ID_LIKE" attribute in the
    `os-release man page
    <http://www.freedesktop.org/software/systemd/man/os-release.html>`_.
    )r,rr2r0r/rr�s���<�<�>�>�r0c�4�t���S)a�
    Return the codename for the release of the current OS distribution,
    as a string.

    If the distribution does not have a codename, an empty string is returned.

    Note that the returned codename is not always really a codename. For
    example, openSUSE returns "x86_64". This function does not handle such
    cases in any special way and just returns the string it finds, if any.

    **Lookup hierarchy:**

    * the codename within the "VERSION" attribute of the os-release file, if
      provided,

    * the value of the "Codename" attribute returned by the lsb_release
      command,

    * the value of the "<codename>" field of the distro release file.
    )r,rr2r0r/rr�s��,�����r0c�8�t�||��S)a�
    Return certain machine-readable information items about the current OS
    distribution in a dictionary, as shown in the following example:

    .. sourcecode:: python

        {
            'id': 'rhel',
            'version': '7.0',
            'version_parts': {
                'major': '7',
                'minor': '0',
                'build_number': ''
            },
            'like': 'fedora',
            'codename': 'Maipo'
        }

    The dictionary structure and keys are always the same, regardless of which
    information items are available in the underlying data sources. The values
    for the various keys are as follows:

    * ``id``:  The result of :func:`distro.id`.

    * ``version``:  The result of :func:`distro.version`.

    * ``version_parts -> major``:  The result of :func:`distro.major_version`.

    * ``version_parts -> minor``:  The result of :func:`distro.minor_version`.

    * ``version_parts -> build_number``:  The result of
      :func:`distro.build_number`.

    * ``like``:  The result of :func:`distro.like`.

    * ``codename``:  The result of :func:`distro.codename`.

    For a description of the *pretty* and *best* parameters, see the
    :func:`distro.version` method.
    )r,�infor8s  r/rErE�s��T�<�<���%�%�%r0c�4�t���S)z�
    Return a dictionary containing key-value pairs for the information items
    from the os-release file data source of the current OS distribution.

    See `os-release file`_ for details about these information items.
    )r,�os_release_infor2r0r/rGrG�s���"�"�$�$�$r0c�4�t���S)z�
    Return a dictionary containing key-value pairs for the information items
    from the lsb_release command data source of the current OS distribution.

    See `lsb_release command output`_ for details about these information
    items.
    )r,�lsb_release_infor2r0r/rIrI�s���#�#�%�%�%r0c�4�t���S)z�
    Return a dictionary containing key-value pairs for the information items
    from the distro release file data source of the current OS distribution.

    See `distro release file`_ for details about these information items.
    )r,�distro_release_infor2r0r/rKrKs���&�&�(�(�(r0c�4�t���S)z�
    Return a dictionary containing key-value pairs for the information items
    from the distro release file data source of the current OS distribution.
    )r,�
uname_infor2r0r/rMrMs�������r0c�6�t�|��S)a�
    Return a single named information item from the os-release file data source
    of the current OS distribution.

    Parameters:

    * ``attribute`` (string): Key of the information item.

    Returns:

    * (string): Value of the information item, if the item exists.
      The empty string, if the item does not exist.

    See `os-release file`_ for details about these information items.
    )r,�os_release_attr��	attributes r/rOrOs��"�"�"�9�-�-�-r0c�6�t�|��S)a�
    Return a single named information item from the lsb_release command output
    data source of the current OS distribution.

    Parameters:

    * ``attribute`` (string): Key of the information item.

    Returns:

    * (string): Value of the information item, if the item exists.
      The empty string, if the item does not exist.

    See `lsb_release command output`_ for details about these information
    items.
    )r,�lsb_release_attrrPs r/rSrS+s��$�#�#�I�.�.�.r0c�6�t�|��S)a�
    Return a single named information item from the distro release file
    data source of the current OS distribution.

    Parameters:

    * ``attribute`` (string): Key of the information item.

    Returns:

    * (string): Value of the information item, if the item exists.
      The empty string, if the item does not exist.

    See `distro release file`_ for details about these information items.
    )r,�distro_release_attrrPs r/rUrU@s��"�&�&�y�1�1�1r0c�6�t�|��S)aZ
    Return a single named information item from the distro release file
    data source of the current OS distribution.

    Parameters:

    * ``attribute`` (string): Key of the information item.

    Returns:

    * (string): Value of the information item, if the item exists.
                The empty string, if the item does not exist.
    )r,�
uname_attrrPs r/rWrWTs�����i�(�(�(r0)�cached_propertyc��eZdZdZd�Zd�ZdS)rXz�A version of @property which caches the value.  On access, it calls the
        underlying function and sets the value in `__dict__` so future accesses
        will not re-call the property.
        c�,�|j|_||_dS)N)�__name__�_fname�_f)�self�fs  r/�__init__zcached_property.__init__ps���*�D�K��D�G�G�Gr0c��|�"Jd�|j�����|�|��x}|j|j<|S)Nzcall {} on an instance)�formatr\r]�__dict__)r^�obj�owner�rets    r/�__get__zcached_property.__get__usD���?�?�$<�$C�$C�D�K�$P�$P�?�?�?�.2�g�g�c�l�l�:�C�#�,�t�{�+��Jr0N)r[�
__module__�__qualname__�__doc__r`rgr2r0r/rXrXjs<������	�	�
	�	�	�
	�	�	�	�	r0rXc�x�eZdZdZ					d%d�Zd�Zd&d�Zd�Zd'd
�Zd(d�Z	d'd�Z
d'd
�Zd'd�Zd'd�Z
d�Zd�Zd(d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed���Zed���Zed���Zed���Zed���Zed ���Z ed!���Z!ed"���Z"d#�Z#ed$���Z$dS))�LinuxDistributiona
    Provides information about a OS distribution.

    This package creates a private module-global instance of this class with
    default initialization arguments, that is used by the
    `consolidated accessor functions`_ and `single source accessor functions`_.
    By using default initialization arguments, that module-global instance
    returns data about the current OS distribution (i.e. the distro this
    package runs on).

    Normally, it is not necessary to create additional instances of this class.
    However, in situations where control is needed over the exact data sources
    that are used, instances of this class can be created with a specific
    distro release file, or a specific os-release file, or without invoking the
    lsb_release command.
    T�Nc�P�||_|r tj�|d��nt|_|r tj�|d��nt|_|r||_n�tj�|jt��}tj�|jt��}tj�
|��stj�
|��s||_n||_|pd|_||_||_
dS)a�
        The initialization method of this class gathers information from the
        available data sources, and stores that in private instance attributes.
        Subsequent access to the information items uses these private instance
        attributes, so that the data sources are read only once.

        Parameters:

        * ``include_lsb`` (bool): Controls whether the
          `lsb_release command output`_ is included as a data source.

          If the lsb_release command is not available in the program execution
          path, the data source for the lsb_release command will be empty.

        * ``os_release_file`` (string): The path name of the
          `os-release file`_ that is to be used as a data source.

          An empty string (the default) will cause the default path name to
          be used (see `os-release file`_ for details).

          If the specified or defaulted os-release file does not exist, the
          data source for the os-release file will be empty.

        * ``distro_release_file`` (string): The path name of the
          `distro release file`_ that is to be used as a data source.

          An empty string (the default) will cause a default search algorithm
          to be used (see `distro release file`_ for details).

          If the specified distro release file does not exist, or if no default
          distro release file can be found, the data source for the distro
          release file will be empty.

        * ``include_uname`` (bool): Controls whether uname command output is
          included as a data source. If the uname command is not available in
          the program execution path the data source for the uname command will
          be empty.

        * ``root_dir`` (string): The absolute path to the root directory to use
          to find distro-related information files.

        Public instance attributes:

        * ``os_release_file`` (string): The path name of the
          `os-release file`_ that is actually used as a data source. The
          empty string if no distro release file is used as a data source.

        * ``distro_release_file`` (string): The path name of the
          `distro release file`_ that is actually used as a data source. The
          empty string if no distro release file is used as a data source.

        * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
          This controls whether the lsb information will be loaded.

        * ``include_uname`` (bool): The result of the ``include_uname``
          parameter. This controls whether the uname information will
          be loaded.

        Raises:

        * :py:exc:`IOError`: Some I/O issue with an os-release file or distro
          release file.

        * :py:exc:`subprocess.CalledProcessError`: The lsb_release command had
          some issue (other than not being available in the program execution
          path).

        * :py:exc:`UnicodeError`: A data source has unexpected characters or
          uses an unexpected encoding.
        �etczusr/librmN)�root_dir�os�path�join�_UNIXCONFDIR�etc_dir�_UNIXUSRLIBDIR�usr_lib_dir�os_release_file�_OS_RELEASE_BASENAME�isfile�distro_release_file�include_lsb�
include_uname)r^r|rxr{r}rp�etc_dir_os_release_file�usr_lib_os_release_files        r/r`zLinuxDistribution.__init__�s
��^!��
�8@�R�r�w�|�|�H�e�4�4�4�l���19�M�B�G�L�L��9�-�-�-�~�	
���	?�#2�D� � �&(�g�l�l�4�<�AU�&V�&V�#�&(�g�l�l�� �"6�'�'�#��w�~�~�5�6�6�
?�b�g�n�n�'�?�?�
?�(?��$�$�'>��$�#6�#<�"�� �&���*����r0c�.�d�|���S)zReturn repr of all infoaeLinuxDistribution(os_release_file={self.os_release_file!r}, distro_release_file={self.distro_release_file!r}, include_lsb={self.include_lsb!r}, include_uname={self.include_uname!r}, _os_release_info={self._os_release_info!r}, _lsb_release_info={self._lsb_release_info!r}, _distro_release_info={self._distro_release_info!r}, _uname_info={self._uname_info!r})�r^)rbr�s r/�__repr__zLinuxDistribution.__repr__�s��
0�17��D��0A�0A�
	
r0c��|r|���n|���|���|���fS)z�
        Return information about the OS distribution that is compatible
        with Python's :func:`platform.linux_distribution`, supporting a subset
        of its parameters.

        For details, see :func:`distro.linux_distribution`.
        )r4rrr)r^r.s  r/r-z$LinuxDistribution.linux_distributions@��2�@�D�I�I�K�K�K�t�w�w�y�y��L�L�N�N��M�M�O�O�
�	
r0c�L�d�}|�d��}|r||t��S|�d��}|r||t��S|�d��}|r||t
��S|�d��}|r||t
��SdS)zoReturn the distro ID of the OS distribution, as a string.

        For details, see :func:`distro.id`.
        c�~�|����dd��}|�||��S)N� �_)�lower�replace�get)�	distro_id�tables  r/�	normalizez'LinuxDistribution.id.<locals>.normalizes5��!���)�)�1�1�#�s�;�;�I��9�9�Y�	�2�2�2r0r�distributor_idrm)rO�NORMALIZED_OS_IDrS�NORMALIZED_LSB_IDrU�NORMALIZED_DISTRO_IDrW)r^r�r�s   r/rzLinuxDistribution.ids���	3�	3�	3�
�(�(��.�.�	��	:��9�Y�(8�9�9�9��)�)�*:�;�;�	��	;��9�Y�(9�:�:�:��,�,�T�2�2�	��	>��9�Y�(<�=�=�=��O�O�D�)�)�	��	>��9�Y�(<�=�=�=��rr0Fc��|�d��p>|�d��p)|�d��p|�d��}|rv|�d��p|�d��}|sJ|�d��p|�d��}|�d���}|r|dz|z}|pdS)	zu
        Return the name of the OS distribution, as a string.

        For details, see :func:`distro.name`.
        r4r��pretty_name�descriptionTr5r�rm)rOrSrUrWr)r^r6r4rs    r/r4zLinuxDistribution.name4s���
� � ��(�(�
'��$�$�%5�6�6�
'��'�'��/�/�
'����v�&�&�		
��	0��'�'�
�6�6��$�:O�:O��;�;�D��
0��/�/��7�7�R�4�?�?�6�;R�;R���,�,�d�,�3�3���0��#�:��/�D��z�r�r0c	��|�d��|�d��|�d��|�|�d�����dd��|�|�d�����dd��|�d��g}d}|r:|D]6}|�d��|�d��ks|dkr|}�7n|D]}|dkr|}n�
|r>|r<|���r(d�||�����}|S)z{
        Return the version of the OS distribution, as a string.

        For details, see :func:`distro.version`.
        �
version_id�releaser�rmr��.z	{0} ({1}))	rOrSrU�_parse_distro_release_contentr�rW�countrrb)r^r6r9�versionsr�vs      r/rzLinuxDistribution.versionLsx��
� � ��.�.��!�!�)�,�,��$�$�\�2�2��.�.�t�/C�/C�M�/R�/R�S�S�W�W��b�
�
�
�.�.��%�%�m�4�4�
�
��c�,��#�#��O�O�I�&�&�
�����	�
�
 �
 ���7�7�3�<�<�'�-�-��"4�"4�4�4��2�
�
��G��
 ��
�
����7�7��G��E���	C�g�	C�$�-�-�/�/�	C�!�(�(��$�-�-�/�/�B�B�G��r0c���|�|���}|rLtjd��}|�|��}|r!|���\}}}||pd|pdfSdS)z�
        Return the version of the OS distribution, as a tuple of version
        numbers.

        For details, see :func:`distro.version_parts`.
        r;z(\d+)\.?(\d+)?\.?(\d+)?rm)rmrmrm)r�re�compile�match�groups)r^r9�version_str�
version_regex�matchesrrrs        r/rzLinuxDistribution.version_partsqs{���l�l��l�-�-���	>��J�'A�B�B�M�#�)�)�+�6�6�G��
>�-4�^�^�-=�-=�*��u�l��e�k�r�<�+=�2�=�=��zr0c�8�|�|��dS)z�
        Return the major version number of the current distribution.

        For details, see :func:`distro.major_version`.
        r�r�r^r9s  r/r=zLinuxDistribution.major_version�����!�!�$�'�'��*�*r0c�8�|�|��dS)z�
        Return the minor version number of the current distribution.

        For details, see :func:`distro.minor_version`.
        �r�r�s  r/r@zLinuxDistribution.minor_version�r�r0c�8�|�|��dS)z}
        Return the build number of the current distribution.

        For details, see :func:`distro.build_number`.
        r'r�r�s  r/rzLinuxDistribution.build_number�r�r0c�0�|�d��pdS)z�
        Return the IDs of distributions that are like the OS distribution.

        For details, see :func:`distro.like`.
        �id_likerm)rOr�s r/rzLinuxDistribution.like�s���#�#�I�.�.�4�"�4r0c��	|jdS#t$r/|�d��p|�d��pdcYSwxYw)zp
        Return the codename of the OS distribution.

        For details, see :func:`distro.codename`.
        rrm)�_os_release_info�KeyErrorrSrUr�s r/rzLinuxDistribution.codename�sp��		��(��4�4���	�	�	��%�%�j�1�1���+�+�J�7�7���
�
�
�	���s��6A�Ac�P�t|���|�||��t|�|��|�|��|�|�����|���|������S)z�
        Return certain machine-readable information about the OS
        distribution.

        For details, see :func:`distro.info`.
        rr)�dictrrr=r@rrr)r^r6r9s   r/rEzLinuxDistribution.info�s�����w�w�y�y��L�L���.�.���(�(��.�.��(�(��.�.�!�.�.�t�4�4����
������]�]�_�_�

�

�

�
	
r0c��|jS)z�
        Return a dictionary containing key-value pairs for the information
        items from the os-release file data source of the OS distribution.

        For details, see :func:`distro.os_release_info`.
        )r�r�s r/rGz!LinuxDistribution.os_release_info�s
���$�$r0c��|jS)z�
        Return a dictionary containing key-value pairs for the information
        items from the lsb_release command data source of the OS
        distribution.

        For details, see :func:`distro.lsb_release_info`.
        )�_lsb_release_infor�s r/rIz"LinuxDistribution.lsb_release_info�s
���%�%r0c��|jS)z�
        Return a dictionary containing key-value pairs for the information
        items from the distro release file data source of the OS
        distribution.

        For details, see :func:`distro.distro_release_info`.
        )�_distro_release_infor�s r/rKz%LinuxDistribution.distro_release_info�s
���(�(r0c��|jS)z�
        Return a dictionary containing key-value pairs for the information
        items from the uname command data source of the OS distribution.

        For details, see :func:`distro.uname_info`.
        )�_uname_infor�s r/rMzLinuxDistribution.uname_info�s
����r0c�8�|j�|d��S)z�
        Return a single named information item from the os-release file data
        source of the OS distribution.

        For details, see :func:`distro.os_release_attr`.
        rm)r�r��r^rQs  r/rOz!LinuxDistribution.os_release_attr�s���$�(�(��B�7�7�7r0c�8�|j�|d��S)z�
        Return a single named information item from the lsb_release command
        output data source of the OS distribution.

        For details, see :func:`distro.lsb_release_attr`.
        rm)r�r�r�s  r/rSz"LinuxDistribution.lsb_release_attrs���%�)�)�)�R�8�8�8r0c�8�|j�|d��S)z�
        Return a single named information item from the distro release file
        data source of the OS distribution.

        For details, see :func:`distro.distro_release_attr`.
        rm)r�r�r�s  r/rUz%LinuxDistribution.distro_release_attr
s���(�,�,�Y��;�;�;r0c�8�|j�|d��S)z�
        Return a single named information item from the uname command
        output data source of the OS distribution.

        For details, see :func:`distro.uname_attr`.
        rm)r�r�r�s  r/rWzLinuxDistribution.uname_attrs����#�#�I�r�2�2�2r0c���tj�|j��rAt	|j��5}|�|��cddd��S#1swxYwYiS)z�
        Get the information items from the specified os-release file.

        Returns:
            A dictionary containing all information items.
        N)rqrrrzrx�open�_parse_os_release_content)r^�release_files  r/r�z"LinuxDistribution._os_release_infos����7�>�>�$�.�/�/�	D��d�*�+�+�
D�|��5�5�l�C�C�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D����
D�
D�
D�
D��	s�A�A�"Ac��i}tj|d���}d|_tjddkr9t	|jt��r|j�d��|_t|��}|D]7}d|vr1|�	dd��\}}|||�
��<�7�8d|vr|d|d	<n�d
|vr|d
|d	<nxd|vrttjd|d��}|rW|�
��}|�d
��}|�d��}|���}||d	<|S)aD
        Parse the lines of an os-release file.

        Parameters:

        * lines: Iterable through the lines in the os-release file.
                 Each line must be a unicode string or a UTF-8 encoded byte
                 string.

        Returns:
            A dictionary containing all information items.
        T)�posixrr'z
iso-8859-1�=r��version_codenamer�ubuntu_codenamerz(\(\D+\))|,(\s+)?\D+z()�,)�shlex�whitespace_split�sys�version_info�
isinstance�	wordchars�bytes�decode�list�splitr�r��search�group�strip)	�lines�props�lexer�tokens�token�kr�r�rs	         r/r�z+LinuxDistribution._parse_os_release_content,sm������E��.�.�.��!%�����A��!�#�#�
�5�?�E�(J�(J�#�#�o�4�4�\�B�B�E�O��e�����	�	�E��e�|�|��{�{�3��*�*���1�#$��a�g�g�i�i� � ����&�&�
!&�&8� 9�E�*���
�%�
'�
'� %�&7� 8�E�*���
�%�
�
��I�5�u�Y�7G�H�H�E��
-� �;�;�=�=��#�>�>�$�/�/��#�>�>�#�.�.��#�>�>�+�+��$,��j�!��r0c�z�|jsiSttjd��5}	d}t	j||���}n*#ttjf$ricYcddd��SwxYw	ddd��n#1swxYwY|�|���	��}|�
|��S)z�
        Get the information items from the lsb_release command output.

        Returns:
            A dictionary containing all information items.
        �wb)�lsb_releasez-a��stderrN)r|r�rq�devnull�
subprocess�check_output�OSError�CalledProcessError�_to_str�
splitlines�_parse_lsb_release_content�r^r��cmd�stdout�contents     r/r�z#LinuxDistribution._lsb_release_infons#����	��I�
�"�*�d�
#�
#�	�w�
�+��#�0��W�E�E�E�����Z�:�;�
�
�
��	�	�
	�	�	�	�	�	�	�	�

�����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��,�,�v�&�&�1�1�3�3���.�.�w�7�7�7s1�A6�?�A6�A&�A6�%A&�&A6�6A:�=A:c�6�i}|D]�}|�d���dd��}t|��dkr�?|\}}|�|�dd�����|���i����|S)aM
        Parse the output of the lsb_release command.

        Parameters:

        * lines: Iterable through the lines of the lsb_release output.
                 Each line must be a unicode string or a UTF-8 encoded byte
                 string.

        Returns:
            A dictionary containing all information items.
        �
�:r�r'r�r�)r�r��len�updater�r�)r�r��line�kvr�r�s      r/r�z,LinuxDistribution._parse_lsb_release_content�s������	C�	C�D����D�!�!�'�'��Q�/�/�B��2�w�w�!�|�|���D�A�q��L�L�!�)�)�C��-�-�3�3�5�5�q�w�w�y�y�A�B�B�B�B��r0c�P�ttjd��5}	d}tj||���}n#t
$ricYcddd��SwxYw	ddd��n#1swxYwY|�|�����}|�|��S)Nr�)�unamez-rsr�)	r�rqr�r�r�r�r�r��_parse_uname_contentr�s     r/r�zLinuxDistribution._uname_info�s���"�*�d�
#�
#�	�w�
�&��#�0��W�E�E�E�����
�
�
��	�	�	�	�	�	�	�	�	�	�
�����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��,�,�v�&�&�1�1�3�3���(�(��1�1�1s1�A!�6�A!�A�A!�A�A!�!A%�(A%c���i}tjd|d�����}|r@|���\}}|dkriS|���|d<||d<||d<|S)Nz^([^\s]+)\s+([\d\.]+)r�Linuxrr4r�)r�r�r�r�r�)r�r�r�r4rs     r/r�z&LinuxDistribution._parse_uname_content�s{�����	�2�E�!�H�N�N�4D�4D�E�E���
	'�!�L�L�N�N�M�D�'�
�w����	��*�*�,�,�E�$�K� �E�&�M�&�E�)���r0c��tj��}|dkrdn|}tjddkr+t|t��r|�|��Sn*t|t��r|�|��S|S)N�asciizutf-8r�)r��getfilesystemencodingr�r�r�r��unicode�encode)�text�encodings  r/r�zLinuxDistribution._to_str�s����,�.�.��&�'�1�1�7�7�x����A��!�#�#��$��&�&�
-��{�{�8�,�,�,�
-��$��(�(�
-��{�{�8�,�,�,��r0c�(�|jr�|�|j��}tj�|j��}t
�|��}d|vr"d|d���vrd|d<n|r|�d��|d<|S	tj	|j
��}|���n#t$rgd�}YnwxYw|D]�}|tvr�t
�|��}|r�tj�|j
|��}|�|��}d|vrD||_|�d��|d<d|d���vrd|d<|cS��iS)z�
        Get the information items from the specified distro release file.

        Returns:
            A dictionary containing all information items.
        r4�
cloudlinuxrr�)zSuSE-releasezarch-releasezbase-releasezcentos-releasezfedora-releasezgentoo-releasezmageia-releasezmandrake-releasezmandriva-releasezmandrivalinux-releasezmanjaro-releasezoracle-releasezredhat-releasez
sl-releasezslackware-version)r{�_parse_distro_release_filerqrr�basename� _DISTRO_RELEASE_BASENAME_PATTERNr�r�r��listdirru�sortr�� _DISTRO_RELEASE_IGNORE_BASENAMESrs)r^�distro_inforr��	basenames�filepaths      r/r�z&LinuxDistribution._distro_release_info�s����#�:	��9�9�$�:R�S�S�K��w�'�'��(@�A�A�H�
5�:�:�8�D�D�E���$�$���V�9L�9R�9R�9T�9T�)T�)T�$0��D�!�!��
3�$)�K�K��N�N��D�!���
��J�t�|�4�4�	���� � � � ���
�
�
�
���	�	�	�
����,&�

+�

+���?�?�?��8�>�>�x�H�H���	+�!�w�|�|�D�L�(�C�C�H�"&�"A�"A�(�"K�"K�K���,�,�3;��0�,1�K�K��N�N��D�)�'�;�v�+>�+D�+D�+F�+F�F�F�0<�K��-�*�*�*�*���Is�#-C�C"�!C"c���	t|��5}|�|�����cddd��S#1swxYwYdS#ttf$ricYSwxYw)z�
        Parse a distro release file.

        Parameters:

        * filepath: Path name of the distro release file.

        Returns:
            A dictionary containing all information items.
        N)r�r��readliner��IOError)r^r�fps   r/rz,LinuxDistribution._parse_distro_release_files���		��h���
I�2��9�9�"�+�+�-�-�H�H�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I����
I�
I�
I�
I�
I�
I����!�	�	�	��I�I�I�		���s3�A�'A�A�A	�	A�A	�
A�A(�'A(c���t�|���ddd���}i}|r�|�d��ddd�|d<|�d��r!|�d��ddd�|d<|�d��r!|�d��ddd�|d<n|r|���|d<|S)	a
        Parse a line from a distro release file.

        Parameters:
        * line: Line from the distro release file. Must be a unicode string
                or a UTF-8 encoded byte string.

        Returns:
            A dictionary containing all information items.
        N���r�r4r'r�r�r)�(_DISTRO_RELEASE_CONTENT_REVERSED_PATTERNr�r�r�)r�r�r	s   r/r�z/LinuxDistribution._parse_distro_release_content%s���;�@�@������d�d�PR�d�AS�T�T�����	/�")�-�-��"2�"2�4�4�R�4�"8�K����}�}�Q���
C�,3�M�M�!�,<�,<�T�T�r�T�,B��L�)��}�}�Q���
A�*1�-�-��*:�*:�4�4�R�4�*@��J�'��
�	/�"&�*�*�,�,�K����r0)TrmrmTN�T�F�FF)%r[rhrirjr`r�r-rr4rrr=r@rrrrErGrIrKrMrOrSrUrWrXr��staticmethodr�r�r�r�r�r�r�rr�r2r0r/rlrl|s���������&�����
h+�h+�h+�h+�T

�

�

�

�

�

�

����<����0#�#�#�#�J����"+�+�+�+�+�+�+�+�+�+�+�+�5�5�5����$
�
�
�
�(%�%�%�	&�	&�	&�	)�	)�	)� � � �8�8�8�9�9�9�<�<�<�3�3�3�����_���?�?��\�?�B�8�8��_�8�(����\��0�	2�	2��_�	2�����\��"����\���B�B��_�B�H���.����\���r0rlc�p�tjt��}|�tj��|�tjtj����tj
d���}|�dddd���|�dd	td
d���|�
��}|jrtd
d
|j���}nt }|jr>|�t#j|���dd�����dS|�d|�d�����|�d���}|�d|��|���}|�d|��dS)NzOS distro info tool)r�z--jsonz-jz!Output in machine readable format�
store_true)�help�actionz
--root-dirz-rrpz5Path to the root filesystem directory (defaults to /))�type�destrF)r|r}rp�T)�indent�	sort_keyszName: %sr5zVersion: %szCodename: %s)�logging�	getLoggerr[�setLevel�DEBUG�
addHandler�
StreamHandlerr�r��argparse�ArgumentParser�add_argument�str�
parse_argsrprlr,�jsonrE�dumpsr4rr)�logger�parser�args�dist�distribution_version�distribution_codenames      r/�mainr3Cs���
�
�x�
(�
(�F�
�O�O�G�M�"�"�"�
���g�+�C�J�7�7�8�8�8�
�
$�1F�
G�
G�
G�F�
����$�@�����������
�
�
D����������D��}�� ��U�T�]�
�
�
������y�;����D�J�t�y�y�{�{�1��E�E�E�F�F�F�F�F����J��	�	��	� 6� 6�7�7�7�#�|�|�4�|�8�8�����M�#7�8�8�8� $�
�
�������N�$9�:�:�:�:�:r0�__main__rrr)Arjr&r+r rqr�r�r�r�r)�__version__�typingrrrrrrr	r
rrr
r)rr�environr�rtrvryr�r�r�r�rrrr-rr4rrr=r@rrrrErGrIrKrMrOrSrUrW�	functoolsrX�ImportError�objectrlr,r3r[r2r0r/�<module>r;sW��
�
�������������	�	�	�	�	�	�	�	���������
�
�
�
�������
�<�z�~�~�m�V�4�4��������<�<��#��	�(���'�"*�#)�$�#)���� 
�f���
,6�2�:�H�,�,�(�
$.�2�:�.L�#M�#M� ��������$� �(>�(>�(>�(>�VM�M�M�`% �% �% �% �P*)�*)�*)�*)�Z'�'�'�'�$'�'�'�'�'�'�'�'�&�&�&�&����$���2*&�*&�*&�*&�Z%�%�%�	&�	&�	&�)�)�)� � � �.�.�.�(/�/�/�*2�2�2�()�)�)�$�)�)�)�)�)�)�)�����������&����������(A�A�A�A�A��A�A�A�H�
�
�
��#;�#;�#;�L�z����D�F�F�F�F�F��s�C$�$C:�9C:

?>