Sindbad~EG File Manager
3
�Pf�$�@s�ddlmZddlZddlZddlZddlmZddlm Z ddl
mZmZddl
mZddlmZmZejd�Zejd �Zejd
�Zejd�Zejd�Zejd
�Zeje�ZGdd�de�Zdd�Zeje�dS)�)�absolute_importN)�parse)�Link)�rmtree�display_path)�
indent_log)�vcs�VersionControlz
url="([^"]+)"zcommitted-rev="(\d+)"z URL: (.+)zRevision: (.+)z\s*revision="(\d+)"z<url>(.*)</url>cs�eZdZdZdZdZd"Zdd �Zd
d�Zdd
�Z dd�Z
dd�Zdd�Zdd�Z
�fdd�Zdd�Zdd�Zdd�Zdd�Zed d!��Z�ZS)#�
Subversion�svnz.svn�checkout�svn+ssh�svn+http� svn+https�svn+svncCs�|jd|gdddid�}tj|�}|sFtjdt|��tjd|�dS|jd �j�}t j|�}|s�tjd
t|��tjd|�|dfS||jd �fS)z/Returns (url, revision), where both are strings�infoFZLANG�C)�show_stdoutZ
extra_environz'Cannot determine URL of svn checkout %sz!Output that cannot be parsed:
%sN�z,Cannot determine revision of svn checkout %s)NN)
�run_command�_svn_url_re�search�logger�warningr�debug�group�strip�_svn_revision_re)�self�location�output�match�url�r#� /usr/lib/python3.6/subversion.py�get_infos(
zSubversion.get_infocCst|j�\}}t||�}|j|�}tjd||�t��6tjj|�rJt |�|j
dg|||gdd�WdQRXdS)z@Export the svn repository at the url to the destination locationz!Exporting svn repository %s to %s�exportF)rN)�get_url_rev�get_rev_options�remove_auth_from_urlrrr�os�path�existsrr)rrr"�rev�rev_optionsr#r#r$r&;s
zSubversion.exportcCs|jdg|||g�dS)N�switch)r)r�destr"r.r#r#r$r/JszSubversion.switchcCs|jdg||g�dS)N�update)r)rr0r.r#r#r$r1MszSubversion.updatecCst|j�\}}t||�}|j|�}|r.d|}nd}|j||||�rptjd||t|��|jddg|||g�dS)Nz (to revision %s)�zChecking out %s%s to %srz-q)r'r(r)Zcheck_destinationrrrr)rr0r"r-r.Zrev_displayr#r#r$�obtainPs
zSubversion.obtaincCsfx`|D]X}t|�j}|sqd|kr@dj|jd�dd��j�}n|}||jkr|jdd�dSqWdS)N�-r�#r���)r�egg_fragment�join�split�lower�key)r�distZdependency_linksr"r7r;r#r#r$�get_locationas
zSubversion.get_locationc
Cs�d}x�tj|�D]�\}}}|j|kr2g|dd�<q|j|j�tjj||jd�}tjj|�s^q|j|�\}}||kr~|d} n |s�|j| �r�g|dd�<qt ||�}qW|S)zR
Return the maximum revision for all files under a given location
rN�entries�/)
r*�walk�dirname�remover+r8r,�_get_svn_url_rev�
startswith�max)
rrZrevision�base�dirs�filesZ
entries_fnZdirurlZlocalrevZbase_urlr#r#r$�get_revisionos"
zSubversion.get_revisioncs,tt|�j�\}}|jd�r$d|}||fS)Nzssh://zsvn+)�superr
r'rD)rr"r-)� __class__r#r$r'�s
zSubversion.get_url_revcCsV|}xBtjjtjj|d��sF|}tjj|�}||krtjd|�dSqW|j|�dS)Nzsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)r)r*r+r,r8rArrrC)rrZ
orig_locationZ
last_locationr#r#r$�get_url�szSubversion.get_urlcCspddlm}tjj||jd�}tjj|�rHt|��}|j�}WdQRXnd}|j d�sj|j d�sj|j d�r�t
ttj
|jd���}|dd=|dd }d
d�|D�dg}n�|j d�r�tj|�}|s�td
|��|jd�}dd�tj|�D�dg}n^y<|jdd|gdd�} tj| �jd�}dd�tj| �D�}Wn |k
�rRdg}}YnX|�rdt|�}
nd}
||
fS)Nr)�InstallationErrorr>r2�8�9Z10z
�cSs,g|]$}t|�dkr|drt|d��qS)� )�len�int)�.0�dr#r#r$�
<listcomp>�sz/Subversion._get_svn_url_rev.<locals>.<listcomp>z<?xmlzBadly formatted data: %rrcSsg|]}t|jd���qS)r)rSr)rT�mr#r#r$rV�srz--xmlF)rcSsg|]}t|jd���qS)r)rSr)rTrWr#r#r$rV�s)Zpip.exceptionsrMr*r+r8rAr,�open�readrD�list�map�str�
splitlinesr9�_svn_xml_url_rer�
ValueErrorr�_svn_rev_re�finditerr�_svn_info_xml_url_re�_svn_info_xml_rev_rerE)rrrMZentries_path�f�datar"Zrevsr!Zxmlr-r#r#r$rC�s>
zSubversion._get_svn_url_revcCsB|j|�}|dkrdS|j�jdd�d}|j|�}d|||fS)Nr4rrzsvn+%s@%s#egg=%s)rLZegg_namer9rI)rr<rZrepoZegg_project_namer-r#r#r$�get_src_requirement�s
zSubversion.get_src_requirementcCsdS)z&Always assume the versions don't matchFr#)rr0r.r#r#r$�
check_version�szSubversion.check_versioncCs>tj|�}|jjd�d}|j||j|j|jf}tj|�}|S)N�@rr6) �urllib_parse�urlsplit�netlocr9�schemer+ZqueryZfragmentZ
urlunsplit)r"ZpurlZstripped_netlocZ
url_piecesZsurlr#r#r$r)�s
zSubversion.remove_auth_from_url)rr
rrr)�__name__�
__module__�__qualname__�namerAZ repo_nameZschemesr%r&r/r1r3r=rIr'rLrCrfrg�staticmethodr)�
__classcell__r#r#)rKr$r
s", r
cCs�|rd|g}ng}tj|�}t|d�r6|j|j}}nL|d}d|krz|jd�d}d|krn|jdd�\}}q�|d}}nd \}}|r�|d|g7}|r�|d|g7}|S)
Nz-r�usernamerrhr�:z
--usernamez
--password)NN)rirj�hasattrrs�passwordr9)r"r-r.�rrsrvrkZauthr#r#r$r(�s$
r()Z
__future__rZloggingr*�reZpip._vendor.six.moves.urllibrriZ pip.indexrZ pip.utilsrrZpip.utils.loggingrZpip.vcsrr �compiler^r`rrrcrbZ getLoggerrmrr
r(�registerr#r#r#r$�<module>s&
Y
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists