R`i
d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl m
Z
mZmZm
Z
mZmZ d dlmZmZmZ d dlmZ d dlmZ ded efd
Zedede
d eeddf fd Z ed
ed ed Z eej: Zded efdZded efdZdeded e
e fdZ ded ee!e"f fdZ#ded efdZ$ded ee!e"f fdZ%ded efdZ&y) N)contextmanager)NamedTemporaryFile)AnyBinaryIO GeneratorListUnioncast)retrystop_after_delay
wait_fixed)get_path_uid)format_sizepathreturnc t j dk( st t d syt j j | sJ d }| |k7 rt j j
| rLt j dk( r t | }|dk( S t j | t j S | t j j | } }| |k7 ry# t $ r Y yw xY w)Nwin32geteuidTr F)
sysplatformhasattrosr isabslexistsr r OSErroraccessW_OKdirname)r previouspath_uids /builddir/build/BUILDROOT/alt-python312-pip-23.3.1-3.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_internal/utils/filesystem.pycheck_path_ownerr" s ||wgb)&<
77==H
(
77??4 zz|q !+D1H 1}$yyrww//!277??4#8dH (
! !s C C,+C,kwargsc + K t ddt j j | t j j | dd|5 }t t | } | |j t j |j ddd y# |j t j |j w xY w# 1 sw Y yxY ww)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# fresults r! adjacent_tmp_filer0 + s
GGOOD!ww%
h" &LLLNHHV]]_%
LLNHHV]]_%
s6 AC$
CB #3C C$ 5CCC!C$T g ?)reraisestopwaitc R t j j | sGt j j | }|| k( rn"|} t j j | sGt j dk( r$t j
| t j S 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 parents r! test_writable_dirr; L su ggmmD!&T> ggmmD!
ww'yyrww''!$'' c d}dt d D ] }|dj fdt d D z }t j j | | } t j |t j
t j z t j z }t j | t j | y t d # t $ r Y t $ r Y yw xY w)
N(accesstest_deleteme_fishfingers_custard_$abcdefghijklmnopqrstuvwxyz0123456789
c 3 H K | ] }t j y wN)randomchoice).0_alphabets r!