%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/debian/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/debian/__pycache__/_arch_table.cpython-312.pyc

�

Cf�c%H���dZddlZ	ddlmZmZmZmZmZmZddlm	Z	ddlZd�Z
ejdgd��ZGd�d	e�ZGd
�d�Zy#e
$rY�9wxYw)a�architecture matching

This leverages code from dpkg's Dpkg::Arch as well as python rewrites from
other people.  Copyright years imported from the sources.

@copyright: 2006-2015 Guillem Jover <guillem@debian.org>
@copyright: 2014, Ansgar Burchardt <ansgar@debian.org>
@copyright: 2014-2017, Johannes Schauer Marin Rodrigues <josch@debian.org>
@copyright: 2022, Niels Thykier <niels@thykier.net>
@license: GPL-2+
�N)�Iterable�Optional�IO�List�Dict�Union)�PathLikec#�K�|D]8}|j�}|r|jd�r�'|j����:y�w)N�#)�rstrip�
startswith�split)�fd�lines  �4/usr/lib/python3/dist-packages/debian/_arch_table.py�_parse_table_filer%s=��������{�{�}���t���s�+���j�j�l��	�s�?A�
_QuadTuple)�api_name�	libc_name�os_name�cpu_namec�2��eZdZdZ�fd�Zed��Z�xZS)�QuadTupleDpkgArchitecturez"Implementation detail of ArchTablec���t|t�rn|jd|jfvxrR|jd|jfvxr6|jd|jfvxr|j
d|j
fvSt�|�|�S�N�any)�
isinstancerrrrr�super�__contains__)�self�item�	__class__s  �rrz&QuadTupleDpkgArchitecture.__contains__4s�����d�5�6��=�=�U�D�M�M�$:�:�?��~�~�%����)@�@�?��|�|��t�|�|�'<�<�?��}�}���
�
�(>�>�
?��w�#�D�)�)�c�&�td�|D��S)Nc3�&K�|]	}|dk(���y�w)rN�)�.0�xs  r�	<genexpr>z8QuadTupleDpkgArchitecture.is_wildcard.<locals>.<genexpr>As����,�!�1��:�,�s�)r)r s r�is_wildcardz%QuadTupleDpkgArchitecture.is_wildcard>s���,�t�,�,�,r#)�__name__�
__module__�__qualname__�__doc__r�propertyr*�
__classcell__)r"s@rrr1s���,�*��-��-r#rc�^�eZdZd�Zedd��Zedd��Zd�Zd�Zd�Z	d�Z
	dd�Zd	�Zy
)
�
DpkgArchTablec�<�||_dtdddd�i|_yr)�_arch2tabler�_wildcard_cache)r �
arch2tuples  r�__init__zDpkgArchTable.__init__Fs%��%����,�U�E�5�%�H� 
��r#c��tjj|d�}tjj|d�}d}tjj|�sCtjj|d�}tjj|�rd}|}t	|d��5}t	|d��5}|j|||��cd	d	d	�cd	d	d	�S#1swYnxYwd	d	d	�y	#1swYy	xYw)
a?Load the Dpkg Architecture Table

        This class method loads the architecture table from dpkg, so it can be used.

        >>> arch_table = DpkgArchTable.load_arch_table()
        >>> arch_table.matches_architecture("amd64", "any")
        True

        The method assumes the dpkg "tuple arch" format version 1.0 or the older triplet format.

        :param path: Choose a different directory for loading the architecture data.  The provided
          directory must contain the architecture data files from dpkg (such as "tupletable" and
          "cputable")
        �
tupletable�cputableF�triplettableTzutf-8)�encoding)�triplet_compatN)�os�path�join�exists�open�
_from_file)�clsr?�tupletable_path�
cputable_pathr=�triplettable_path�tuple_fd�cpu_fds        r�load_arch_tablezDpkgArchTable.load_arch_tableMs���&�'�'�,�,�t�\�:�������T�:�6�
����w�w�~�~�o�.� "�����T�>� B���w�w�|�|�-�.�!%��"3��
�/�G�
4�	S���]�W�5�	S�9?��>�>�(�F�>�>�R�	S�	S�	S�	S��	S�	S�	S�s$�2C<�C'�	C<�'C0	�,C<�<Dc�j�i}t|�D�cgc]}|d��	}}t|�D]y}|d}|d}	|rd|z}d|vrG|D]A}
|jd|
�}|	jd|
�}t|jdd��||<�C�_t|jdd��||	<�{t	|�Scc}w)Nr�zbase-z<cpu>�-�)r�replacerrr2)
rD�tuple_table_fd�cpu_table_fdr=r6r(�cpu_list�row�
dpkg_tuple�	dpkg_archr�debtuple_cpu�
dpkg_arch_cpus
             rrCzDpkgArchTable._from_filems����
�"3�L�"A�B�Q�A�a�D�B��B�$�^�4�	]�C��Q��J��A��I��$�z�1�
��*�$� (��H�#-�#5�#5�g�x�#H�L�$-�$5�$5�g�x�$H�M�0I�%�+�+�C��3�1�J�}�-��)B�:�CS�CS�TW�YZ�C[�(\�
�9�%�!	]�"�Z�(�(��%Cs�B0c� �	|j|S#t$rYnwxYw|jdd�}d|vr8t|�dkr!|j	dd�t|�dkr�!t|�}n|j
|�}||j|<|S)NrMrNr�r)r5�KeyErrorr�len�insertr�_dpkg_arch_to_tuple)r �arch�
arch_tuple�results    r�_dpkg_wildcard_to_tuplez%DpkgArchTable._dpkg_wildcard_to_tuple�s���	��'�'��-�-���	��	���Z�Z��Q�'�
��J���j�/�A�%��!�!�!�U�+��j�/�A�%�.�
�;�F��-�-�d�3�F�%+����T�"��
s��	�c�L�|jd�r|dd}|j|S)Nzlinux-�)r
r4)r rUs  rr]z!DpkgArchTable._dpkg_arch_to_tuple�s,������)�!�!�"�
�I����	�*�*r#c�|�|d|fvry	|j|�}|j|�}||vS#t$rYywxYw)a�Determine if a dpkg architecture matches another architecture or a wildcard [debarch_is]

        This method is the closest match to dpkg's Dpkg::Arch::debarch_is function.

        >>> arch_table = DpkgArchTable.load_arch_table()
        >>> arch_table.matches_architecture("amd64", "linux-any")
        True
        >>> arch_table.matches_architecture("i386", "linux-any")
        True
        >>> arch_table.matches_architecture("amd64", "amd64")
        True
        >>> arch_table.matches_architecture("i386", "amd64")
        False
        >>> arch_table.matches_architecture("all", "amd64")
        False
        >>> arch_table.matches_architecture("all", "all")
        True
        >>> # i386 is the short form of linux-i386. Therefore, it does not match kfreebsd-i386
        >>> arch_table.matches_architecture("i386", "kfreebsd-i386")
        False
        >>> # Note that "armel" and "armhf" are "arm" CPUs, so it is matched by "any-arm"
        >>> # (similar holds for some other architecture <-> CPU name combinations)
        >>> all(arch_table.matches_architecture(n, 'any-arm') for n in ['armel', 'armhf'])
        True
        >>> # Since "armel" is not a valid CPU name, this returns False (the correct would be
        >>> # any-arm as noted above)
        >>> arch_table.matches_architecture("armel", "any-armel")
        False
        >>> # Wildcards used as architecture always fail (except for special cases noted in the
        >>> # compatibility notes below)
        >>> arch_table.matches_architecture("any-i386", "i386")
        False
        >>> # any-i386 is not a subset of linux-any (they only have i386/linux-i386 as overlap)
        >>> arch_table.matches_architecture("any-i386", "linux-any")
        False
        >>> # Compatibility with dpkg - if alias is `any` then it always returns True
        >>> # even if the input otherwise would not make sense.
        >>> arch_table.matches_architecture("any-unknown", "any")
        True
        >>> # Another side effect of the dpkg compatibility
        >>> arch_table.matches_architecture("all", "any")
        True

        Compatibility note: The method emulates Dpkg::Arch::debarch_is function and therefore
        returns True if both parameters are the same even though they are wildcards or not known
        to be architectures. Additionally, if `alias` is `any`, then this method always returns
        True as `any` is the "match-everything-wildcard".

        :param architecture: A string representing a dpkg architecture.
        :param alias: A string representing a dpkg architecture or wildcard
               to match with.
        :returns: True if the `architecture` parameter is (logically) the same as the `alias`
                  parameter OR, if `alias` is a wildcard, the `architecture` parameter is a
                  subset of the wildcard.
                  The method returns False if `architecture` is not a known dpkg architecture,
                  or it is a wildcard.
        rTF)r]rarZ)r �architecture�aliasrU�
dpkg_wildcards     r�matches_architecturez"DpkgArchTable.matches_architecture�s]��v�U�L�)�)��	��0�0��>�I� �8�8��?�M��M�)�)���	��	�s�"/�	;�;c�|�||k(ry	|j|�}|j|�}||k(S#t$rYywxYw)a�Determine whether two dpkg architecture are exactly the same [debarch_eq]

        Unlike Python's `==` operator, this method also accounts for things like `linux-amd64` is
        a valid spelling of the dpkg architecture `amd64` (i.e.,
        `architecture_equals("linux-amd64", "amd64")` is True).

        This method is the closest match to dpkg's Dpkg::Arch::debarch_eq function.

        >>> arch_table = DpkgArchTable.load_arch_table()
        >>> arch_table.architecture_equals("linux-amd64", "amd64")
        True
        >>> arch_table.architecture_equals("amd64", "linux-i386")
        False
        >>> arch_table.architecture_equals("i386", "linux-amd64")
        False
        >>> arch_table.architecture_equals("amd64", "amd64")
        True
        >>> arch_table.architecture_equals("i386", "amd64")
        False
        >>> # Compatibility with dpkg: if the parameters are equal, then it always return True
        >>> arch_table.architecture_equals("unknown", "unknown")
        True

        Compatibility note: The method emulates Dpkg::Arch::debarch_eq function and therefore
        returns True if both parameters are the same even though they are wildcards or not known
        to be architectures.

        :param arch1: A string representing a dpkg architecture.
        :param arch2: A string representing a dpkg architecture.
        :returns: True if the dpkg architecture parameters are (logically) the exact same.
        TF)r]rZ)r �arch1�arch2�
dpkg_arch1�
dpkg_arch2s     r�architecture_equalsz!DpkgArchTable.architecture_equals�sW��B�E�>��	��1�1�%�8�J��1�1�%�8�J��Z�'�'���	��	�s�"/�	;�;c�P�d}d}d}t|�}	|j|�}|D]Y}	|	dk(r�	|	ddk(rd}nd}|��|	j�}	d}
|	}|	ddk(rd}
|	dd}|j	|�}||vs�R|
}|s�W|cS|s|r
|rtd��|�|}|S#t$rYywxYw)	a�	Determine if a dpkg architecture is part of a list of restrictions [debarch_is_concerned]

        This method is the closest match to dpkg's Dpkg::Arch::debarch_is_concerned function.

        Compatibility notes:
          * The Dpkg::Arch::debarch_is_concerned function allow matching of negative and positive
            restrictions by default.  Often, this behaviour is not allowed nor recommended and the
            Debian Policy does not allow this practice in e.g., Build-Depends.  Therefore, this
            implementation defaults to raising ValueError when this occurs.  If the original
            behaviour is needed, set `allow_mixing_positive_and_negative` to True.
          * The Dpkg::Arch::debarch_is_concerned function is lazy and exits as soon as it finds a
            match. This means that if negative and positive restrictions are mixed, then order of
            the matches are important. This adaption matches that behaviour (provided that
            `allow_mixing_positive_and_negative` is set to True)

        >>> arch_table = DpkgArchTable.load_arch_table()
        >>> arch_table.architecture_is_concerned("linux-amd64", ["amd64", "i386"])
        True
        >>> arch_table.architecture_is_concerned("amd64", ["!amd64", "!i386"])
        False
        >>> # This is False because the "!amd64" is matched first.
        >>> arch_table.architecture_is_concerned("linux-amd64", ["!linux-amd64", "linux-any"],
        ...                                      allow_mixing_positive_and_negative=True)
        False
        >>> # This is True because the "linux-any" is matched first.
        >>> arch_table.architecture_is_concerned("linux-amd64", ["linux-any", "!linux-amd64"],
        ...                                      allow_mixing_positive_and_negative=True)
        True

        :param architecture: A string representing a dpkg architecture/wildcard.
        :param architecture_restrictions: A list of positive (amd64) or negative (!amd64) dpkg
                                          architectures or/and wildcards.
        :param allow_mixing_positive_and_negative: If True, the `architecture_restrictions` list
                                       can mix positive and negative (e.g., ["!any-amd64", "any"])
                                       restrictions. If False, mixing will trigger a ValueError.
        :returns: True if `architecture` is accepted by the `architecture_restrictions`.
        NF�r�!TrLz�architecture_restrictions contained mixed positive and negativerestrictions (and allow_mixing_positive_and_negative was not True))�iterr]rZ�lowerra�
ValueError)
r re�architecture_restrictions�"allow_mixing_positive_and_negative�verdict�positive_match_seen�negative_match_seen�arch_restriction_iterrU�arch_restriction�verdict_if_matched�arch_restriction_positivergs
             r�architecture_is_concernedz'DpkgArchTable.architecture_is_concerneds)��\��#��#�� $�%>� ?��	��0�0��>�I�!6�!	#�� �2�%����"�c�)�&*�#�&*�#��"�� 0�5�5�7��!%��(8�%���"�c�)�%*�"�,<�Q�R�,@�)� �8�8�9R�S�M��M�)�,��5�#�N�C!	#�F2�6I�Na��b�c�
c��?�)�G����_�	��	�s�B�	B%�$B%c�\�	|j|�}|jS#t$rYywxYw)a�Determine if a given string is a dpkg wildcard [debarch_is_wildcard]

        This method is the closest match to dpkg's Dpkg::Arch::debarch_is_wildcard function.

        >>> arch_table = DpkgArchTable.load_arch_table()
        >>> arch_table.is_wildcard("linux-any")
        True
        >>> arch_table.is_wildcard("amd64")
        False
        >>> arch_table.is_wildcard("unknown")
        False
        >>> # Compatibility with the dpkg version of the function.
        >>> arch_table.is_wildcard("unknown-any")
        True

        Compatibility note: The original dpkg function does not ensure that the wildcard matches
          any supported architecture and this re-implementation matches that behaviour.  Therefore,
          this method can return True for a wildcard that can never match anything in practice.

        :param wildcard: A string that might represent a dpkg architecture or wildcard.
        :returns: True the parameter is a known dpkg wildcard.
        F)rar*rZ)r �wildcardrUs   rr*zDpkgArchTable.is_wildcardws9��0	)��4�4�X�>�I�
�(�(�(��	�	��	�s��	+�+N)z/usr/share/dpkg)F)
r+r,r-r7�classmethodrJrCrar]rhrnr~r*r&r#rr2r2Ds[��
��S��S�>�)��)�.�&+�D*�L*(�ZFK�d�L)r#r2)r.r>�typingrrrrrrr	�ImportError�collections.abc�collectionsr�
namedtuplerrr2r&r#r�<module>r�sk��
�2
�	�@�@����$�[�
#�
#�L�2b�
c�
�-�
�-�&Q)�Q)��K�	��	�s�A�A�A

Zerion Mini Shell 1.0