Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/version_utils/__pycache__/rpm.cpython-39.pyc
Ðазад
a ]�h�A � @ s� d Z ddlmZmZmZmZ ddlmZ ddlm Z ddl mZ ddlm Z e d�Zee�ZdZd ZdZd&dd�Zd d� Zdd� Zdd� Zd'dd�Zd(dd�Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Z d%S ))a) rpm module for version_utils Contains RPM parsing and comparison operations for version_utils. Public methods include: * :any:`compare_packages`: compare two RPM package strings, e.g. ``gcc-4.4.7-16.el6.x86_64`` and ``gcc-4.4.7-17.el6.x86_64`` * :any:`compare_versions`: compare two RPM version strings (the bit between the dashes in an RPM package string) * :any:`package`: parse an RPM package string to get name, epoch, version, release, and architecture information. Returns as a :any:`common.Package` object. � )�absolute_import�division�print_function�unicode_literals)� getLogger)�compile)�Package)�RpmErrorz#(\S+)-(?:(\d*):)?(.*)-(~?\w+[\w.]*)� ���Tc C s4 t �d| |� t| |�d }t||�d }t||�S )aD Compare two RPM strings to determine which is newer Parses version information out of RPM package strings of the form returned by the ``rpm -q`` command and compares their versions to determine which is newer. Provided strings *do not* require an architecture at the end, although if providing strings without architecture, the ``arch_provided`` parameter should be set to False. Note that the packages do not have to be the same package (i.e. they do not require the same name or architecture). :param str rpm_str_a: an rpm package string :param str rpm_str_b: an rpm package string :param bool arch_provided: whether package strings contain architecture information :return: 1 (``a`` is newer), 0 (versions are equivalent), or -1 (``b`` is newer) :rtype: int zresolve_versions(%s, %s)�EVR)�logger�debug� parse_package�labelCompare)Z rpm_str_aZ rpm_str_bZ arch_provided�evr_a�evr_b� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/version_utils/rpm.py�compare_packages) s r c C sP | \}}}|\}}}||kr,||kr(t S tS t||�}|tkrB|S t||�} | S )a8 Compare two EVR tuples to determine which is newer This method compares the epoch, version, and release of the provided package strings, assuming that epoch is 0 if not provided. Comparison is performed on the epoch, then the version, and then the release. If at any point a non-equality is found, the result is returned without any remaining comparisons being performed (e.g. if the epochs of the packages differ, the versions are releases are not compared). :param tuple evr_a: an EVR tuple :param tuple evr_b: an EVR tuple )�a_newer�b_newer�compare_versions�a_eq_b) r r Za_epochZa_verZa_relZb_epochZb_verZb_relZver_compZrel_compr r r �compare_evrsD s r c C s t | |�S )a� Convenience function to provide the same behaviour as labelCompare from rpm-python. To be used as a drop-in replacement for labelCompare, thus the utilization of the non-standard camelCase variable name. To use the version_utils version and fall back to rpm: try: from version_utils.rpm import labelCompare except ImportError: from rpm import labelCompare :param tuple evr_a: an EVR tuple :param tuple evr_b: an EVR tuple )r )r r r r r r _ s r c C sx t �d| |� | |krtS zt| �t|� }}W n" tyR td�| |���Y n0 t|�dk�rt|�dk�rt �d||� t||� |d dkr�|d dkr�|� d� |� d� qTn |d dkr�t S |d dkr�tS t|�dks�t|�dkr�qt||�}|tkrT|S qTt|�t|�k�r,t �d� tS t �d� t|�t|�k�r^|d dk�rZt S tS |d dk�rptS t S dS ) a} Compare two RPM version strings Compares two RPM version strings and returns an integer indicating the result of the comparison. The method of comparison mirrors that used by RPM, so results should be the same for any standard RPM package. To perform the comparison, the strings are first checked for equality. If they are equal, the versions are equal. Otherwise, each string is converted to a character list, and a comparison loop is started using these lists. In the comparison loop, first any non-alphanumeric, non-~ characters are trimmed from the front of the list. Then if the first character from both ``a`` and ``b`` is a ~ (tilde), it is trimmed. The ~ (tilde) character indicates that a given package or version should be considered older (even if it is numerically larger), so if ``a`` begins with a tilde, ``b`` is newer, and vice-versa. At this point, if the length of either list has been reduced to 0, the loop is exited. If characters remain in the list, the :any:`_get_block_result` function is used to pop consecutive digits or letters from the front of hte list and compare them. The result of the block comparison is returned if the blocks are not equal. The loop then begins again. If the loop exits without returning a value, the lengths of the remaining character lists are compared. If they have the same length (usually 0, since all characters have been popped), they are considered to be equal. Otherwise, whichever is longer is considered to be newer, unless it starts with a ~, in which case it is considered be older. Generally, unequal length will be due to one character list having been completely consumed while some characters remain on the other, for example when comparing 1.05b to 1.05. :param unicode version_a: An RPM version or release string :param unicode version_b: An RPM version or release string :return: 1 (if ``a`` is newer), 0 (if versions are equal), or -1 (if ``b`` is newer) :rtype: int :raises RpmError: if an a type is passed that cannot be converted to a list zcompare_versions(%s, %s)zCould not compare {0} to {1}r z starting loop comparing %s to %s�~zversions are equalzversions not equalN) r r r �list� TypeErrorr �format�len�_check_leading�popr r �_get_block_result)Z version_aZ version_b�chars_a�chars_bZ block_resr r r r s sD +�� r c C sP t �d| |� t| |�}t|d |d d |d d |d d |d | d�}|S ) aH Parse an RPM version string Parses most (all tested) RPM version strings to get their name, epoch, version, release, and architecture information. Epoch (also called serial) is an optional component for RPM versions, and it is also optional when providing a version string to this function. RPM assumes the epoch to be 0 if it is not provided, so that behavior is mirrored here. :param str package_string: :param bool arch_included: :return: A :any:`common.Package` object containing all parsed information :rtype: common.Package zpackage(%s, %s)�namer r r � �arch)Zpackage_str)r r r r )�package_string� arch_included�pkg_info�pkgr r r �package� s �r, c C s� t �d| |� d}d}|r@t| �}t|�}d�|�} t �d| � zt�| ��� \}}}}W n tyx t d| ��Y n0 |dks�|du r�|}||||f|d�} t �d| � | S ) a] Parse an RPM version string to get name, version, and arch Splits most (all tested) RPM version strings into name, epoch, version, release, and architecture. Epoch (also called serial) is an optional component of RPM versioning and is also optional in version strings provided to this function. RPM assumes the epoch to be 0 if it is not provided, so that behavior is mirrored here. **Deprecated** since version 0.2.0. Use :any:`rpm.package` instead. :param str package_string: an RPM version string of the form returned by the ``rpm -q`` command :param bool arch_included: default True - version strings may optionally be provided without the trailing architecture. If providing such strings, set this option to False :return: a dictionary with all parsed package information :rtype: dict zparse_package(%s, %s)�0N� zupdated version_string: %sz"Could not parse package string: %s)r% r r'