File: //usr/local/CyberPanel/lib64/python3.10/site-packages/tldextract/__pycache__/cache.cpython-310.pyc
o
�h�! � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl m
Z
mZmZ ddl
mZ ddlmZmZ ddlZddlmZ e�e�Zdaed �Zejd
krXd'dd�ZnejZd(dd�Zd(dd�ZG dd� d�Zd)dd�Zd*d!d"�Z d+d%d&�Z!dS ),zHelpers.� )�annotationsN)�Callable�Hashable�Iterable)�Path)�TypeVar�cast)�FileLockF�T)� � �args�bytes�return�
hashlib._Hashc G s t j| ddi�S )zUse argument only available in newer Python.
In this file, MD5 is only used for cache location, not security.
�usedforsecurityF)�hashlib�md5)r
� r �F/usr/local/CyberPanel/lib/python3.10/site-packages/tldextract/cache.pyr s r �strc C s� zddl m} W n ty d} Y nw d| }tj�tj�}ttj� d���
� dd� }d�d d
� tjdd� D ��}||||g}d�|�}|S )
z�Generate an identifier unique to the python version, tldextract version, and python instance.
This will prevent interference between virtualenvs and issues that might arise when installing
a new version of tldextract
r )�version�devztldextract-�utf-8N� �.c S s g | ]}t |��qS r )r )�.0�vr r r �
<listcomp>7 s z-get_pkg_unique_identifier.<locals>.<listcomp>����__)
�tldextract._versionr �ImportError�os�path�basename�sys�prefixr �encode� hexdigest�join�version_info)r �tldextract_version�python_env_name�python_binary_path_short_hash�python_version�identifier_parts�pkg_identifierr r r �get_pkg_unique_identifier( s ��
r2 c C s| t j�dd�} | dur
| S t �dd�}|du r&t �dd�}|r&tt|d��}|dur3tt|dt� ��S ttt j�t �d��S )z�Get a cache dir that we have permission to write to.
Try to follow the XDG standard, but if that doesn't work fallback to the package directory
http://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
�TLDEXTRACT_CACHEN�XDG_CACHE_HOME�HOMEz.cachezpython-tldextractz
.suffix_cache)
r# �environ�get�getenvr r r2 r$ �dirname�__file__)� cache_dir�xdg_cache_home� user_homer r r �
get_cache_dirC s �r>