Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/__pycache__/compat.cpython-35.pyc



t_%@sdZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZerddlmZmZmZmZmZmZmZedZGdd	d	eZyddlZWn_ek
rcydd
lmZWn6ek
r^ddlZeje_ej e_!YnXYnXddd
dddddgZ"ej#e$Z%erddl&Z&y
e&j'Z'Wne(k
rdZ'YnXe'dk	Z)ndZ)ddl*m'Z'erddZ+ej,de+dZ-ndZ-ddZ.dddZ/dd
Z0ddZ1dd Z2d!d"d#hZ3e
j4j5d$pe
j4d%koej6d&kZ7d'dZ8e9e	drd(dZ:nd)dZ:dd*d+Z;e<ed,e;Z=dS)-zKStuff that differs in different Python versions and platform
distributions.)absolute_importdivisionN)PY2	text_type)MYPY_CHECK_RUNNING)CallableOptionalProtocolTextTupleTypeVarUnionFc@seZdZdddZdS)LruCacheNcCs
tdS)N)NotImplementedError)selfmaxsizer/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/compat.py__call__szLruCache.__call__)__name__
__module____qualname__rrrrrrsr)	ipaddressruses_pycacheconsole_to_strget_path_uidstdlib_pkgsWINDOWSsamefileget_terminal_sizeT)cache_from_sourcecs]fddtjjD}dd|D}djtdj|jfS)Nc3s|]}j|VqdS)N)object).0i)errrr	<genexpr>Isz-backslashreplace_decode_fn.<locals>.<genexpr>css|]}t|VqdS)N)ord)r#brrrr&Ksz\x{:x})rangestartendjoinmapformat)r%Z	raw_bytesr)r%rbackslashreplace_decode_fnHs(r0backslashreplace_decodebackslashreplacecCs=yddl}dSWntk
r(YnXddlm}|S)NrT)IS_PYOPENSSL)_sslImportErrorpip._vendor.urllib3.utilr3)r4r3rrrhas_tlsVs
r7c
Cst|tr|Stj}|s>tj|jdkrDd}y|j|}Wn@tk
rt	j
d|pyd||j|dt}YnXttt
dddd}|r|j|dd	}|j|}|S)
a
    For display or logging purposes, convert a bytes object (or text) to
    text (e.g. unicode in Python 2) safe for output.

    :param desc: An optional phrase describing the input data, for use in
        the log message if a warning is logged. Defaults to "Bytes object".

    This function should never error out and so can take a best effort
    approach. It is okay to be lossy if needed since the return value is
    just for display.

    We assume the data is in the locale preferred encoding. If it won't
    decode properly, we warn the user but decode as best we can.

    We also ensure that the output can be safely written to standard output
    without encoding errors.
    asciizutf-8z&%s does not appear to be encoded as %szBytes objecterrors
__stderr__Nencodingr2)
isinstancerlocalegetpreferredencodingcodecslookupnamedecodeUnicodeDecodeErrorloggerwarningr1getattrsysencode)datadescr;decoded_dataoutput_encodingoutput_encodedrrrstr_to_displaybs*
		rNcCst|ddS)z<Return a string, safe for output, of subprocess output.
    rJzSubprocess output)rN)rIrrrrscCsttdrMtj|tjtjB}tj|j}tj|n<tjj	|sttj
|j}ntdj||S)a)
    Return path's uid.

    Does not follow symlinks:
        https://github.com/pypa/pip/pull/935#discussion_r5307003

    Placed this function in compat due to differences on AIX and
    Jython, that should eventually go away.

    :raises OSError: When path is a symlink or can't be read.
    
O_NOFOLLOWz1{} is a symlink; Will not return uid for symlinks)
hasattrosopenO_RDONLYrOfstatst_uidclosepathislinkstatOSErrorr/)rWfdfile_uidrrrrs
cCsDtjj|}|jdr@|jdr@|dd}|S)zm
    Expand ~ and ~user constructions.

    Includes a workaround for https://bugs.python.org/issue14768
    z~/z//N)rQrW
expanduser
startswith)rWexpandedrrrr^sr^pythonwsgirefargparsewinclintcCsottjdr%tjj||Stjjtjj|}tjjtjj|}||kSdS)z>Provide an alternative for os.path.samefile on Windows/Python2rN)rPrQrWrnormcaseabspath)file1file2path1path2rrrrs
cCsttjS)z
        Returns a tuple (x, y) representing the width(x) and the height(y)
        in characters of the terminal window.
        )tupleshutilr rrrrr scCsdd}|dp-|dp-|d}|stjdkry8tjtjtj}||}tj|Wntk
rYnX|stjj	ddtjj	d	d
f}t
|dt
|dfS)z
        Returns a tuple (x, y) representing the width(x) and the height(y)
        in characters of the terminal window.
        cSsyyLddl}ddl}ddl}|jd|j||jd}Wntk
rddSYnX|dkrudS|S)NrhhZ12345678)rr)fcntltermiosstructunpack_fromZioctl
TIOCGWINSZ	Exception)r[rprqrrcrrrrioctl_GWINSZs
	z'get_terminal_size.<locals>.ioctl_GWINSZrr]win32LINESCOLUMNSP)rGplatformrQrRctermidrSrVruenvirongetint)rwrvr[rrrr s$
*cCsdd}|S)NcSs|S)Nr)frrr_wrappersz noop_lru_cache.<locals>._wrapperr)rrrrrnoop_lru_cachesr	lru_cache)>__doc__
__future__rrr?	functoolsr=loggingrQrnrGZpip._vendor.sixrrpip._internal.utils.typingrtypingrrr	r
rrr
rrrr5pip._vendoripaddrZ	IPAddress
ip_addressZ	IPNetwork
ip_network__all__	getLoggerrrDimpr!AttributeErrorrimportlib.utilr0register_errorr1r7rNrrr^rr~r_rArrrPr rrFrrrrr<module>sp4

	

	C$
Back to Directory File Manager