관리-도구
편집 파일: __init__.cpython-36.opt-1.pyc
3 �ft`� � @ s� d dl mZ d dl mZ ddlmZ d dlmZ d dlZd dl Zd dl Z dd� Zd d � Zdd� Z e dJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dE��ZdFdG� ZdHdI� ZdS )a� )�absolute_import)�unicode_literals� )�transaction)�is_py3bytesNc ) C s� t j| d�}|jtjtjB � �xztjjD �]l}tj j rDt|d�}y|jd|�}W n< t tjfk r� } ztjjdt|� ��W Y dd}~X nX t|�s�q,yt|�}W n$ tk r� d}tjj|��Y nX |d }y�y|tj j|�}W n, tk �r |tj j|jd��}Y nX |tj | } |tj | } | tjk�rd| �rd|d ||jd�fk�rd| }W n tttfk �r� Y nX t|��r�t|d�}|S W dS ) z-Calculate the release version for the system.)�rootzutf-8Zprovidesz Error: %sNz:Error: rpmdb failed to list provides. Try: rpm --rebuilddb�version�utf8�name)r �initReadOnlyTransactionZpushVSFlags�rpmZ_RPMVSF_NOSIGNATURESZ_RPMVSF_NODIGESTS�dnf�constZDISTROVERPKGZpycompZPY3�bytesZdbMatch� TypeError�error� exceptions�Error�str�len�next� StopIterationZRPMTAG_PROVIDENAME�index� ValueError�decodeZRPMTAG_PROVIDEFLAGSZRPMTAG_PROVIDEVERSIONZRPMSENSE_EQUAL�KeyError� IndexErrorr )Zinstallroot�tsZdistroverpkg�idx�e�hdr�msgZ releaseverZoff�flagZver� r# �/usr/lib/python3.6/__init__.py�detect_releasever sB & r% c C sp t j� }t| ��V}|j� }y|j|�}W n8 tjk r` } ztjj dj || ���W Y dd}~X nX |S Q R X dS )zReturn RPM header of the file.z {0}: '{1}'N)r r �open�filenoZhdrFromFdnor r r r r �format)�pathr �packageZfdnor r r# r# r$ �_headerI s &r+ c s � fdd�� D �S )Nc s i | ]}� | D ] }||�qqS r# r# )�.0�k�v)�dctr# r$ � <dictcomp>V s z_invert.<locals>.<dictcomp>r# )r/ r# )r/ r$ �_invertU s r1 �aarch64�alpha�alphaev4� alphaev45�alphaev5� alphaev56�alphaev6� alphaev67� alphaev68�alphaev7� alphapca56� armv5tejl�armv5tel�armv5tl�armv6l�armv7l�armv8l�armv6hl�armv7hl�armv7hnl�armv8hl�i386�athlon�geode�i486�i586�i686�ia64�mips�mipsel�mips64�mips64el�noarch�ppc�ppc64�ppc64iseries�ppc64p7�ppc64pseries�ppc64le�riscv32�riscv64�riscv128�s390�s390x�sh3�sh4�sh4a�sparc�sparc64�sparc64v�sparcv8�sparcv9�sparcv9v�x86_64�amd64�ia32e)r2 r3 ZarmZarmhfprG rM rN rO rP rQ rR rS rT rX rY rZ r[ r\ r] r^ r_ ra rg c C s t | S )N)� _BASEARCH_MAP)Zarchr# r# r$ �basearchu s rk c C s | | }t |�rt|d�}|S )z� Returns value of rpm_hdr[key] as a string. Rpm has switched from bytes to str and we need to handle both properly. zutf-8)r r )Zrpm_hdr�key�valuer# r# r$ � getheaderz s rn )r2 ) r3 r4 r5 r6 r7 r8 r9 r: r; r<