File: //var/opt/nydus/ops/primordial/__pycache__/utils.cpython-39.pyc
a
�,�h' � @ sN d dl Z d dlmZmZ d dlmZ d dlmZmZm Z m
Z
mZmZm
Z
dZe �e�ZG dd� de�Ze
e e
e d�d d
�Zeeef e e eeef d�dd
�Zeeef e e eeef d�dd�Zd ed�eeed�dd�Zd dd�eeed�dd�Zefedddfeee df eee
e
egef e
e
egef d�dd�ZdS )� N)�partial�update_wrapper)�sleep)�Any�Dict�Iterable�Optional�Tuple�Type�Callable� c @ s e Zd ZdZdS )�RetriesExhaustedErrorz9A special type which signals the failure of a retry loop.N)�__name__�
__module__�__qualname__�__doc__� r r �A/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/primordial/utils.pyr
s r
)�hostname�returnc C sF | du rdS | � � �d�r&| dd� } | �d�D ]}|r0| S q0| S )z�Abbreviate hostname for use on a Windows machine.
:param hostname: the hostname
:returns: the first non-empty domain in the hostname, excluding "www."
Nzwww.� �.)�lower�
startswith�split)r �domainr r r �abbreviate_hostname_for_windows s
r )�dict_�keysr c s � fdd�| � � D �S )a Filter a dictionary to contain only a certain set of keys.
:param dict_: The original dictionary to be filtered.
:param keys: A list, or other iterable, containing the desired dictionary keys.
:returns: A dictionary containing only the desired keys.
c s i | ]\}}|� v r||�qS r r ��.0�k�v�r r r �
<dictcomp>+ � zsubdict.<locals>.<dictcomp>��items�r r r r# r �subdict$ s r) c s � fdd�| � � D �S )z�Filter a dictionary to omit a set of keys.
:param dict_: The original dictionary to be filtered.
:param keys: An iterable containing the keys to omit.
:returns: A dictionary with the desired keys omitted.
c s i | ]\}}|� vr||�qS r r r r# r r r$ 5 r% z subdict_omit.<locals>.<dictcomp>r&