%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/path.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZddlmZddlmZddlmZy&ddlZddlmZeZWne k
r%e!ZnXej"e#�Z$d	�Z%d
�Z&d�Z'd�Z(ed
�dd��Z*d�Z+ed�d��Z,d�Z-d�Z.dd�Z/d�Z0dS(uw
Platform independent versions of some os/os.path functions. Gets around PY2's
lack of support for reading NTFS links.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandNotFoundError(tmemoize(tjinja_filter(tsix(terrorcC@s�tjstjjj�r,tjj|�St	sEt
jd|�nt|�sUt
St|�}|skt
Stjd�}|j||j �\}|d@dks�t
StSdS(u(
    Equivalent to os.path.islink()
    u6Cannot check if %s is a link, missing required modulesuLI���I�N(RtPY3tsalttutilstplatformt
is_windowstostpathtislinkt
HAS_WIN32FILEtlogRt_is_reparse_pointtFalset_get_reparse_datatstructtStructtunpacktsizetTrue(Rtreparse_datat
header_parsert
ReparseTag((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyR'sc	C@s�tjstjjj�r)tj|�StsBt	j
d|�nt|�}|srtt
jdj|���ntjd�}|j||j �\}|d@dks�tt
jdj|���ntjd�}|j||j �\}}}}}}	}
}|j}||}
||
|
|!}|jd�}|jd	�rT|d
}nytj|�}WnKtk
r�}|jd�r�tjdd
|�S|jdkr�|S�nX|S(u%
    Equivalent to os.readlink()
    u(Cannot read %s, missing required modulesuInvalid argument: '{0}'uLI���I�uB{0} is not a symlink, but another type of reparse point (0x{0:X}).uLHHHHHHLuUTF-16u\??\iuUNC\u^UNC\\+u\\\\i(RRR	R
RRR
treadlinkRRRRtOSErrorterrnotEINVALtformatRRRRtdecodet
startswitht	win32filetGetLongPathNamet
pywinerrortretsubtwinerror(RRRRtdata_parsertReparseDataLengthtReservedtSubstituteNameOffsettSubstituteNameLengthtPrintNameOffsettPrintNameLengthtFlagstpath_buffer_offsettabsolute_substitute_name_offsetttarget_bytesttargettexc((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyRJs>
.	

cC@s1tj|�}|dkrtS|d@r-tStS(uC
    Returns True if path is a reparse point; False otherwise.
    i����i(R$tGetFileAttributesWRR(Rtresult((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyR�scC@s�tjj|�}t|�s"dSd}z:tj|ddddd	�}tj|ddd�}Wd|r{tj|�nX|S(
u
    Retrieves the reparse point data structure for the given path.

    If the path is not a reparse point, None is returned.

    See http://msdn.microsoft.com/en-us/library/ff552012.aspx for details on the
    REPARSE_DATA_BUFFER structure returned.
    I�iii ii�	i@Ni (	R
RtnormpathRtNoneR$tCreateFileWtDeviceIoControltCloseHandle(Rt
fileHandletreparseData((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyR�s(
	
uwhichc	@s�d�}�ru|��r�Stjjjtjjdtd���jtd���t	��fd��}tjjj
tjjdd��}|jtj�}tjjj
�s�|jgdD]}||kr�|^q��nxu|D]m}t|��}||�r|Stjjj
�r�|�r�x)�D]}|||�r6||Sq6Wq�q�Wtjd
�|�n
tjd�dS(u(
    Python clone of /usr/bin/which
    cS@s7tj|tj�o6tjj|�p6tjj|�S(N(R
taccesstX_OKRtisfileR(texe((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyt_is_executable_file_or_link�suPATHEXTu.EXEu;c@s�x�D]w}yZdjtjjj|�jd��}tj|tjjj��tj�j	�t
SWqtk
r}qqXqWtS(um
            Do a case insensitive test if exe has a file extension match in
            PATHEXT
            u.*\.{0}$u.(
R!R	R
tstringutilst
to_unicodetlstripR'tmatchtItgroupsRtAttributeErrorR(texttpattern(RCtext_list(s3/usr/lib/python2.7/site-packages/salt/utils/path.pyt_exe_has_ext�s
!
uPATHuu/binu/sbinu/usr/binu	/usr/sbinu/usr/local/binu:'%s' could not be found in the following search path: '%s'uBNo executable was passed to be searched by salt.utils.path.which()(u/binu/sbinu/usr/binu	/usr/sbinu/usr/local/binN(R	R
REtto_strR
tenvirontgettstrtsplittreal_memoizeRFtpathsepRRtextendtjoinRttraceRR:(	RCRDROtsystem_pathtsearch_pathtxRt	full_pathRL((RCRNs3/usr/lib/python2.7/site-packages/salt/utils/path.pytwhich�s8	$




cC@sDt|tj�sdSx'|D]}t|�}|s;qn|SWdS(uT
    Scan over some possible executables and return the first one that is found
    N(t
isinstancetcollectionstIterableR:R^(texesRCR((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyt	which_bins
u	path_joinc
O@s^tjrEg}x*|D]"}|jtjjj|��qW|}ntjjj|�}|j	dt
�}|r�tjjj|�n|r�tnt
j}g|D]}|j|�^q�}y|j	d�}Wntk
r�dSXtjjj|�}|s|}nFg|D]}|jt
j�^q}	|j|tjjj|	��}|j|�S(uw
    This functions tries to solve some issues when joining multiple absolute
    paths on both *nix and windows platforms.

    See tests/unit/utils/path_join_test.py for some examples on what's being
    talked about here.

    The "use_posixpath" kwarg can be be used to force joining using poxixpath,
    which is useful for Salt fileserver paths on Windows masters.
    u
use_posixpathiu(RRtappendR	R
RERPtargstclean_kwargstpopRtinvalid_kwargst	posixpathR
RR9t
IndexErrorRFRGtsepRXtdataR"(
tpartstkwargst	new_partstpartt
use_posixpathtpathlibtptroottrettstripped((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyRXs*	
 	"
	%!cC@sC|dkrtd��nt|�s?tdj|���ndS(u�
    Simple convenience function for modules to use for gracefully blowing up
    if a required tool is not available in the system path.

    Lazily import `salt.modules.cmdmod` to avoid any sort of circular
    dependencies.
    u'None' is not a valid command.u'{0}' is not in the pathN(R:RR^R!(tcommand((s3/usr/lib/python2.7/site-packages/salt/utils/path.pytcheck_or_die>scC@s�d}t|tj�r:|jtd�|D���}nat|tj�r�dt|�}tjrwdj||�nt	j||�}|j|�}n|S(u4
    Remove illegal path characters for windows
    u<>:|?*cs@s!|]}t|�dfVqdS(u_N(tord(t.0tc((s3/usr/lib/python2.7/site-packages/salt/utils/path.pys	<genexpr>Ssu_u(
R_Rt	text_typet	translatetdicttstring_typestlenRt	maketranststring(twinpathtintabtouttabttrantab((s3/usr/lib/python2.7/site-packages/salt/utils/path.pytsanitize_win_pathMs"-c	C@stjjdd�}ddtj|�f}|rOt|t�rO|g}nt�}|r�x'|D]}|jtj|��qeWnt}x8|D]0}tj	||dtj
�dk	r�t}q�q�W|s
x;|D]0}tj	||dtj
�dk	r�t}q�q�Wn|S(u
    .. versionadded:: 2017.7.3

    Checks that the path is safe for modification by Salt. For example, you
    wouldn't want to have salt delete the contents of ``C:\Windows``. The
    following directories are considered unsafe:

    - C:\, D:\, E:\, etc.
    - \
    - C:\Windows

    Args:

        path (str): The path to check

        allow_paths (str, list): A directory or list of directories inside of
            path that may be safe. For example: ``C:\Windows\TEMP``

    Returns:
        bool: True if safe, otherwise False
    u
SystemRootu
C:\Windowsu
[a-z]\:\\$u\\$tflagsN(
R
RQRRR'tescapeR_tlistRdRRHt
IGNORECASER:R(	Rt
allow_pathtsystem_roott
deny_pathstallow_pathstitemt	good_pathtd_pathta_path((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyt	safe_path[s&	

!

!co@swtjr$tjjj�r$|}ntjjj|�}x7tj	|||�D] }tjj
j|dt�VqOWdS(u]
    This is a helper than ensures that all paths returned from os.walk are
    unicode.
    tpreserve_tuplesN(
RtPY2R	R
RRRERPR
twalkRlR"R(ttopReRnt	top_queryR�((s3/usr/lib/python2.7/site-packages/salt/utils/path.pytos_walk�s
	(1t__doc__t
__future__RRRR`RtloggingR
RiR'R�Rtsalt.utils.argsR	tsalt.utils.platformtsalt.utils.stringutilstsalt.exceptionsRtsalt.utils.decoratorsRRUtsalt.utils.decorators.jinjaRtsalt.extRR$t
pywintypesRR&RRtImportErrorRt	getLoggert__name__RRRRRR:R^RcRXRxR�R�R�(((s3/usr/lib/python2.7/site-packages/salt/utils/path.pyt<module>sF


	#	?		(	G	+		9

Zerion Mini Shell 1.0