U
ʗRe @ sf d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl m
Z
mZmZm
Z
mZmZ d dlmZmZmZ d dlmZ d dlmZ eedd d
Zeee
eeddf ddd
ZedededdZeejZeedddZeedddZeee
e dddZ eee!e"f dddZ#eedddZ$eee!e"f dddZ%eeddd Z&dS )! N)contextmanager)NamedTemporaryFile)AnyBinaryIO GeneratorListUnioncast)retrystop_after_delay
wait_fixed)get_path_uid)format_size)pathreturnc C s t jdksttdsdS tj| s(td }| |krtj| rt dkrxzt | }W n t
k
rn Y dS X |dkS t| tjS q,| tj
| }} q,dS )Nwin32geteuidTr F)sysplatformhasattrosr isabsAssertionErrorlexistsr r
OSErroraccessW_OKdirname)r previouspath_uid r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/filesystem.pycheck_path_owner s r" )r kwargsr c k sf t f dtj| tj| dd|4}tt|}z
|V W 5 | t| X W 5 Q R X dS )a% Return a file-like object pointing to a tmp file next to path.
The file is created securely and is ensured to be written to disk
after the context reaches its end.
kwargs will be passed to tempfile.NamedTemporaryFile to control
the way the temporary file will be opened.
Fz.tmp)deletedirprefixsuffixN)
r r r r basenamer r flushfsyncfileno)r r# fresultr r r! adjacent_tmp_file+ s
r. T g ?)reraisestopwaitc C sH t j| s(t j| }|| kr"q(|} q t jdkr@t | t jS t| S )zgCheck if a directory is writable.
Uses os.access() on POSIX, tries creating files on Windows.
posix)r r isdirr namer r _test_writable_dir_win)r parentr r r! test_writable_dirL s
r8 c s d}d t dD ]}|d fddt dD }tj| |}zt|tjtjB tjB }W n* tk
rt Y q t k
r Y dS X t
| t| d S qtd
d S )N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789
c 3 s | ]}t V qd S N)randomchoice).0_alphabetr r!