Your IP : 3.148.145.219


Current Path : /opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/svn_utils.cpython-34.pyc

�
M�Re�E�@siddlZddlZddlZddlmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZyddlZWn!ek
r�ddljZYnXddlmZmZeedddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Ze�Zddd�Z dd�Z!ddd�Z"dd�Z#dd�Z$Gdd�de%�Z&Gdd �d e&�Z'Gd!d"�d"e'�Z(Gd#d$�d$e&�Z)dd%d&�Z*Gd'd(�d(e%�Z+Gd)d*�d*e+�Z,Gd+d,�d,e+�Z-e.d-krex(e*ej/d.�D]Z0e1e0�qNWndS)/�N)�log)�unicode)�unescape)�Popen�PIPEcCspy;t|d|d|dtjdk�}|j�|}Wntk
rSdSYnXt||�}|j|fS)N�stdout�stderr�shell�win32��)rr)�_Popen�sys�platform�communicate�OSError�decode_as_string�
returncode)�argsrr�encoding�stream�proc�data�r�//tmp/pip-l4uy7dan-build/setuptools/svn_utils.py�_run_commands
	rcCs0|jd�d}djdd�|jD��S)N�schedulerrcSs+g|]!}|j|jkr|j�qSr)�nodeType�	TEXT_NODE�	nodeValue)�.0�trrr�
<listcomp>2s	z'_get_entry_schedule.<locals>.<listcomp>)�getElementsByTagName�join�
childNodes)�entryrrrr�_get_entry_schedule0sr'cCs0|jd�d}djdd�|jD��S)N�propertyrrcSs+g|]!}|j|jkr|j�qSr)rrr)r r!rrrr"9s	z(_get_target_property.<locals>.<listcomp>)r#r$r%)�targetZ
property_textrrr�_get_target_property7sr*cCs+tjdkr!|jd�}n|}|S)N�rzutf-8)r+r)r�version_info�encode)�decoded_strrrrr�
_get_xml_data>sr/cGs6|s|dkr#tjj|�Stjj||�S)N�.)�os�pathr$)�prefix�suffixrrr�joinpathGsr5cCs�yLtj�}|s"|dkr5tj�d}n|rKtj|�nWn!tjtfk
rod}YnXtjdk}|s�ddg|S|j	d�r�|r�dS|SdS)NzUS-ASCIIr�darwinzutf-8zmac-)
�locale�getpreferredencoding�getdefaultlocale�codecs�lookup�Error�LookupErrorrr�
startswith)r�is_osxrrr�determine_console_encodingLsr@cCsL|dkrt}nt|t�s6|j|�}ntjd|�}|S)a�
    Decode the console or file output explicitly using getpreferredencoding.
    The text paraemeter should be a encoded string, if not no decode occurs
    If no encoding is given, getpreferredencoding is used.  If encoding is
    specified, that is used instead.  This would be needed for SVN --xml
    output.  Unicode is explicitly put in composed NFC form.

    --xml should be UTF-8 (SVN Issue 2938) the discussion on the Subversion
    DEV List from 2007 seems to indicate the same.
    NZNFC)�_console_encoding�
isinstancer�decode�unicodedata�	normalize)�textrrrrris
	rcCs�tjjjt|��}t�}x||D]t\}}|dkr+|jdkr+|j|�t|�j	d�s�|j
|jd�|jd�f�q�q+q+W|dd�S)z+Parse the entries from a recursive info xml�
START_ELEMENTr&�deleter2�kindrN)�xml�dom�pulldom�parseStringr/�list�nodeName�
expandNoder'r>�append�getAttribute)r.�doc�entries�event�noderrr�parse_dir_entries�s	
rWrc	Cstjj|�}tjj|�}tjjjt|��}t	�}x�|D]�\}}|dkrO|j
dkrO|j|�tjj|jd��}tjj|�j
|�r�|t|�dd�}nt|�}x-t|�D]}|jt||��q�WqOqOW|S)z!Parse a propget svn:externals xmlrGr)r2rN)r1r2�normpath�normcaserJrKrLrMr/rNrOrPrRr>�lenr*�parse_external_proprQr5)	r.r3rS�	externalsrUrVr2r�externalrrr�parse_externals_xml�s	
!r^cCs�g}x�|j�D]�}|j�}|s1qntjdkrR|jd�}ntj|�}tjd	kr�dd�|D�}ntj|d
�dr�|d}n
|d}t	|dd�}|j
tjj
|��qW|S)z�
    Parse the value of a retrieved svn:externals entry.

    possible token setups (with quotng and backscaping in laters versions)
        URL[@#] EXT_FOLDERNAME
        [-r#] URL EXT_FOLDERNAME
        EXT_FOLDERNAME [-r#] URL
    r+rzutf-8cSsg|]}|jd��qS)zutf-8)rC)r �xrrrr"�s	z'parse_external_prop.<locals>.<listcomp>rr)r+r)r+r���r`)�
splitlines�lstriprr,r-�shlex�split�urlparse�urlsplitrrQr1r2rX)�linesr\�liner]rrrr[�s 	

r[c	
Cs�d}t|d�}d}z�x�t|jd�D]}|j�}t|�dkr1|\}}|jt|��}|dkr�||kr�d}q�|dkr�|r�Pq�q1q1WWd|j�X|S)NF�rtr��KT�V)�open�iter�readlinerdrZ�read�int�close)	�filename�key�found�frrh�partsrI�lengthrrr�parse_prop_file�s	ryc@s�eZdZdZedd��Zejdej�Z	e
ddd��Zddd	�Zd
d�Z
edd
��Zedd��Zdd�Zdd�Zddd�Zdd�Zdd�ZdS)�SvnInfoz�
    Generic svn_info object.  No has little knowledge of how to extract
    information.  Use cls.load to instatiate according svn version.

    Paths are not filesystem encoded.
    cCs?tdddg�\}}|dkr7|r7|j�SdSdS)N�svnz	--versionz--quietrr)r�strip)�coderrrr�get_svn_version�s
zSvnInfo.get_svn_versionz!(?:([\-0-9]+):)?(\d+)([a-z]*)\s*$rc	Cshtjj|�}tdd|g�\}}tjj|d�}tjjtjj|d��p�tjjtjj|d��p�tjjtjj|d��}t|j�jd��}y'tdd	�|dd
�D��}Wnt	k
rt�}YnX|st
|�S|s.|s.|dkrHtjd
t
�t|�S|dkr^t|�St|�S)Nr{�infoz.svnrTz	dir-propsz
dir-prop-baser0css|]}t|�VqdS)N)rq)r r_rrr�	<genexpr>szSvnInfo.load.<locals>.<genexpr>rjrr+z?No SVN 1.3+ command found: falling back on pre 1.7 .svn parsing�)rr+)rr�)r1r2rXrr$�isfile�tupler~rd�
ValueErrorrz�warnings�warn�DeprecationWarning�SvnFileInfo�	Svn13Info�	Svn15Info)	�cls�dirname�normdirr}rZsvn_dirZhas_svn�svn_versionZbase_svn_versionrrr�load�s(!!!'

	

zSvnInfo.loadcCs||_d|_d|_dS)N)r2�_entries�
_externals)�selfr2rrr�__init__s		zSvnInfo.__init__cCshtdd|jg�\}}|r5tjd�dS|jj|�}|r`t|jd��SdSdS)z<Retrieve the directory revision informatino using svnversionZ
svnversionz-czsvnversion failedrrjN)rr2rr��revision_re�matchrq�group)r�r}r�parsedrrr�get_revisions
zSvnInfo.get_revisioncCs(|jdkr!|j�|_n|jS)N)r��get_entries)r�rrrrT(szSvnInfo.entriescCs(|jdkr!|j�|_n|jS)N)r��
get_externals)r�rrrr\.szSvnInfo.externalsccsx|jD]}|Vq
WdS)zR
        Iterate over the svn:external references in the repository path.
        N)r\)r��itemrrr�iter_externals4szSvnInfo.iter_externalsccs8x1|jD]&\}}|j�dkr
|Vq
q
WdS)zR
        Iterate over the non-deleted file entries in the repository path
        �fileN)rT�lower)r�r�rIrrr�
iter_files;szSvnInfo.iter_filesTccsI|r|jVnx1|jD]&\}}|j�dkr|VqqWdS)zR
        Iterate over the non-deleted file entries in the repository path
        �dirN)r2rTr�)r�Zinclude_rootr�rIrrr�	iter_dirsCs
zSvnInfo.iter_dirscCsgS)Nr)r�rrrr�MszSvnInfo.get_entriescCsgS)Nr)r�rrrr�PszSvnInfo.get_externalsN)�__name__�
__module__�__qualname__�__doc__�staticmethodr~�re�compile�Ir��classmethodr�r�r�r(rTr\r�r�r�r�r�rrrrrz�s


rzc@s(eZdZdd�Zdd�ZdS)r�cCsKtdddd|jgdd�\}}|rAtjd�gSt|�S)Nr{rz-Rz--xmlrzutf-8zsvn info failed)rr2r�debugrW)r�r}rrrrr�Us
zSvn13Info.get_entriescCs�dddg}g}x�|j�D]�}t||gdd�\}}|dkrdtjd�gSxKt|�D]=}|r�tjj||�}n|jtjj	|��qqWq"W|S)Nr{�propgetz
svn:externalsrzutf-8rzsvn propget failed)
r�rrr�r[r1r2r$rQrX)r��cmd�result�folderr}rgr]rrrr�_s
!zSvn13Info.get_externalsN)r�r�r�r�r�rrrrr�Ts
r�c@seZdZdd�ZdS)r�cCsiddd|jddg}t|dd�\}}|rJtjd�gSt|d	tjj|j��S)
Nr{r�z
svn:externalsz-Rz--xmlrzutf-8zsvn propget failedr3)r2rrr�r^r1�abspath)r�r�r}rgrrrr�ss
zSvn15Info.get_externalsN)r�r�r�r�rrrrr�rsr�csaeZdZd�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z�S)r�rcs,tt|�j|�d|_d|_dS)N)�superr�r�Z_directories�	_revision)r�r2)�	__class__rrr�~s	zSvnFileInfo.__init__ccs�t|dd�}tjj|�r�tj|�}|d|j�fVx�|j�D]x}t|�}t||�}tjj|�r�|ddfVqTtjj	|�rTx|j
|�D]}|Vq�WqTqTWndS)Nz.svnrTFT)r5r1r2r��SVNEntriesFiler��parse_revision�get_undeleted_recordsr�isdir�	_walk_svn)r��base�
entry_filerTr2r�rrrr��szSvnFileInfo._walk_svncCs�t�}d}xa|j|j�D]M\}}}|rM|j|df�q"|j|df�t||�}q"W||_||_dS)Nrr�r�)rNr�r2rQ�maxr�r�)r�rT�revr2r�Zdir_revrrr�_build_entries�s	"	zSvnFileInfo._build_entriescCs#|jdkr|j�n|jS)N)r�r�)r�rrrr��s
zSvnFileInfo.get_entriescCs#|jdkr|j�n|jS)N)r�r�)r�rrrr��s
zSvnFileInfo.get_revisioncCs�ddgddgg}g}x�|j�D]�}d}x8|D]0}t||�}tjj|�r>|}q>q>W|dk	r+t|d�}t|dd�}|jt|��q+q+W|S)Nz.svnz
dir-prop-basez	dir-propsz
svn:externalsrzutf-8)	r�r5r1r2r�ryr�extendr[)r�Z
prop_filesr\r�Z	prop_fileZ	rel_partsrsZext_proprrrr��s	

zSvnFileInfo.get_externals)	r�r�r�r�r�r�r�r�r�rr)r�rr�|sr�ccsqtj|�}x|j�D]}|VqWx?|j�D]1}tj|�}x|j�D]}|VqZWq8WdS)N)rzr�r�r�)r�rr2Zsub_infoZsub_pathrrr�
svn_finder�s	r�c@sLeZdZdd�Zedd��Zedd��Zdd�Zd	S)
r�cCs
||_dS)N)r)r�rrrrr��szSVNEntriesFile.__init__c
CsItjj|dd�}t|�}ztj|�}Wd|j�X|S)Nz.svnrT)r1r2r$rmr�rprr)�class_r�rsrvr�rrrr��szSVNEntriesFile.loadcCs5|j�}|jd�}ttg|}||�S)Nz<?xml)rpr>�SVNEntriesFileText�SVNEntriesFileXML)r��fileobjrZis_xmlrrrrp�szSVNEntriesFile.readcCs|j�dg}t|�S)Nr)�parse_revision_numbersr�)r�Zall_revsrrrr��szSVNEntriesFile.parse_revisionN)r�r�r�r�r�r�rpr�rrrrr��s
r�c@sseZdZidd6dd6dd6Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dS)r��z1.4.x�	z1.5.x�
z1.6.xcCs|jS)N)�sections)r�rrrZ__get_cached_sections�sz(SVNEntriesFileText.__get_cached_sectionscCs�d}|jj|�}dd�ttj|�D�}yEt|djd��}||jj�kr{t	j
d|�nWntk
r�dSYnX||_|j
|_|jS)Nz
cSsg|]}|�qSrr)r r_rrrr"�s	z3SVNEntriesFileText.get_sections.<locals>.<listcomp>rzUnknown subversion verson %d)rrd�map�strrarq�pop�known_svn_versions�valuesrr�r�r��(_SVNEntriesFileText__get_cached_sections�get_sections)r�ZSECTION_DIVIDERr�r�rrrr��s
		zSVNEntriesFileText.get_sectionscCst|j��S)N)�boolr�)r�rrr�is_valid�szSVNEntriesFileText.is_validcCs|j�ddS)Nr�)r�)r�rrr�get_urlszSVNEntriesFileText.get_urlcs)d��fdd�|j�D�}|S)Nr�cs<g|]2}t|��kr|�rt|���qSr)rZrq)r �section)�revision_line_numberrrr"s	z=SVNEntriesFileText.parse_revision_numbers.<locals>.<listcomp>)r�)r�Zrev_numbersr)r�rr�sz)SVNEntriesFileText.parse_revision_numberscs/dd���fdd�|j�D�}|S)NcSs0|o/|do/t|�dkp/|ddkS)Nr�r�rH)rZ)�srrr�<lambda>sz:SVNEntriesFileText.get_undeleted_records.<locals>.<lambda>cs&g|]}�|�r|d�qS)rr)r r�)�	undeletedrrr"s	z<SVNEntriesFileText.get_undeleted_records.<locals>.<listcomp>)r�)r�r�r)r�rr�sz(SVNEntriesFileText.get_undeleted_recordsN)
r�r�r�r�r�r�r�r�r�r�rrrrr��s

r�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCsdS)NTr)r�rrrr�szSVNEntriesFileXML.is_validcCs(tjd�}|j|j�jd�S)zGet repository URLz
url="([^"]+)"r)r�r��searchrr�)r�Zurlrerrrr�szSVNEntriesFileXML.get_urlcCs,tjd�}dd�|j|j�D�S)Nzcommitted-rev="(\d+)"cSs%g|]}t|jd���qS)r)rqr�)r �mrrrr"$s	z<SVNEntriesFileXML.parse_revision_numbers.<locals>.<listcomp>)r�r��finditerr)r�Zrevrerrrr�!s	z(SVNEntriesFileXML.parse_revision_numberscCs8tjdtj�}dd�|j|j�D�}|S)Nz%name="([^"]+)"(?![^>]+deleted="true")cSs%g|]}t|jd���qS)r)rr�)r r�rrrr",s	z;SVNEntriesFileXML.get_undeleted_records.<locals>.<listcomp>)r�r�r�r�r)r�Zentries_pattern�resultsrrrr�(s	z'SVNEntriesFileXML.get_undeleted_recordsN)r�r�r�r�r�r�r�rrrrr�sr��__main__r)2r1r�r�	distutilsrZxml.dom.pulldomrJrcr7r:rDr�Zsetuptools.compatr�xml.sax.saxutilsrre�ImportError�urllib.parse�parse�
subprocessrr
rZ_PIPErr'r*r/r5r@rArrWr^r[ry�objectrzr�r�r�r�r�r�r�r��argv�name�printrrrr�<module>sN
		$t
B
3

?>