HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/pathlib_mate/mate_tool_box.pyc
�
�´ac@szddlZddlZddlZddlZddlmZddlmZddlm	Z	de	fd��YZ
dS(i����Ni(tall_true(trepr_data_size(t
ToolBoxZiptToolBoxcBs�eZd�Zed��Zed��Zed��Zed�Ze	d�Z
dd�Zdd�Zdd	�Z
ed
�Zed�Zd�Zdd
�Zd�d�Zd�ZRS(cCse|�}xO|jdt�D];}|jt|�jd��|j|jjd��qW|j�S(Nt	recursivesutf-8(tselect_filetTruetupdatetstrtencodetmd5t	hexdigest(tselft	hash_methtmtp((spathlib_mate/mate_tool_box.pytget_dir_fingerprints
	cCs|jtj�S(N(RthashlibR
(R((spathlib_mate/mate_tool_box.pytdir_md5scCs|jtj�S(N(RRtsha256(R((spathlib_mate/mate_tool_box.pyt
dir_sha256scCs|jtj�S(N(RRtsha512(R((spathlib_mate/mate_tool_box.pyt
dir_sha512scCs�|j�r�|j�r%|jdkS|j�r~|rYtt|jdt���dkStt|jdt���dkSq�d|}t	|��nt	d|��dS(s�
        - If it's a file, check if it is a empty file. (0 bytes content)
        - If it's a directory, check if there's no file and dir in it.
            But if ``strict = False``, then only check if there's no file in it.

        :param strict: only useful when it is a directory. if True, only
            return True if this dir has no dir and file. if False, return True
            if it doesn't have any file.
        iRs5'%s' is not either file or directory! (maybe simlink)s'%s' not exists!N(
texiststis_filetsizetis_dirtlentlisttselectRRtEnvironmentError(Rtstricttmsg((spathlib_mate/mate_tool_box.pytis_empty!s

"%
cs|j�|jj��|r0�fd�}n�fd�}t�}|j�r�|j|�x�|j|jdt��D]}|j|�q}Wnm|j}|j�r�xU|j|jdt��D]%}||j�r�|j|�q�q�Wnt	d|��|S(s�
        A command line auto complete similar behavior. Find all item with same
        prefix of this one.

        :param case_sensitive: toggle if it is case sensitive.
        :return: list of :class:`pathlib_mate.pathlib2.Path`.
        cs
|j��S(N(t
startswith(tbasename(t
self_basename(spathlib_mate/mate_tool_box.pytmatchDscs|j�j��S(N(tlowerR"(R#(tself_basename_lower(spathlib_mate/mate_tool_box.pyR%GsRs'%s' directory does not exist!(
R#R&RRtappendtsort_by_abspathRtFalsetparentt
ValueError(Rtcase_sensitiveR%tchoicesRtp_parent((R$R'spathlib_mate/mate_tool_box.pytauto_complete_choices9s"		
"	"icCs�|j�tg|jdt�D]}||jf^q dd�dt�}x2|| D]&\}}djt|�|j�GHqXWdS(s6
        Print ``top_n`` big dir in this dir.
        RtkeycSs|dS(Ni((tx((spathlib_mate/mate_tool_box.pyt<lambda>bttreverses{:<9}    {:<9}N(	tassert_is_dir_and_existstsortedt
select_dirR*tdirsizeRtformatRtabspath(Rttop_nRt
size_tableR((spathlib_mate/mate_tool_box.pyt
print_big_dirZs
.		cCs�|j�tg|jdt�D]}||jf^q dd�dt�}x2|| D]&\}}djt|�|j�GHqXWdS(s7
        Print ``top_n`` big file in this dir.
        RR1cSs|dS(Ni((R2((spathlib_mate/mate_tool_box.pyR3pR4R5s{:<9}    {:<9}N(R6R7RRRR:RR;(RR<RR=R((spathlib_mate/mate_tool_box.pytprint_big_filehs
.		c	Cs�|j�tg|jdt�D]}||jf^q dd�dt�}x�|| D]�\}}djt|�|j�GHtg|j	dt�D]}||j
f^q�dd�dt�}x2|| D]&\}}djt|�|j�GHq�WqXWdS(	sDPrint ``top_n`` big dir and ``top_n`` big file in each dir.
        RR1cSs|dS(Ni((R2((spathlib_mate/mate_tool_box.pyR3}R4R5s{:<9}    {:<9}cSs|dS(Ni((R2((spathlib_mate/mate_tool_box.pyR3�R4s    {:<9}    {:<9}N(R6R7R8R*R9RR:RR;RR(	RR<Rtsize_table1tp1tsize1tsize_table2tp2tsize2((spathlib_mate/mate_tool_box.pytprint_big_dir_and_big_filevs
.		.		cCsR|j�ddlm}|�}idd6dd6dd6||j<x|jd|dt�D]�}|j�r�|j}x�|j}||jdcd	7<||jdc|7<|j|jkr�Pn|}q|Wq^|j	�r^idd6dd6dd6||j<xC|j}||jdcd	7<|j|jkr=Pn|}qWq^q^W|S(
s�
        Find out how many files, directories and total size (Include file in
        it's sub-folder) it has for each folder and sub-folder.

        :returns: stat, a dict like ``{"directory path": {
          "file": number of files, "dir": number of directories,
          "size": total size in bytes}}``

        **中文文档**

        返回一个目录中的每个子目录的, 文件, 文件夹, 大小的统计数据。
        i����(tOrderedDictitfiletdirRtfiltersRi(
R6tcollectionsRGR;RRRRR+R(RRJRGtstatRRR+((spathlib_mate/mate_tool_box.pytfile_stat_for_all�s.
	"		
"	cCs�|j�idd6dd6dd6}xq|jd|dt�D]W}|j�rv|dcd7<|dc|j7<q>|j�r>|dcd7<q>q>W|S(sTFind out how many files, directorys and total size (Include file in
        it's sub-folder).

        :returns: stat, a dict like ``{"file": number of files,
          "dir": number of directorys, "size": total size in bytes}``

        **中文文档**

        返回一个目录中的文件, 文件夹, 大小的统计数据。
        iRHRIRRJRi(R6RRRRR(RRJRLR((spathlib_mate/mate_tool_box.pyt	file_stat�s
c
Cs�|j�|j}tjj|�}tjj|�rFtd��nt�}t�}x�tj|j�D]z\}}}|j||�}ytj	|�WnnXx;|D]3}tjj
||�}	t|	d��}WdQXq�WqkWdS(s�
        Create a new folder having exactly same structure with this directory.
        However, all files are just empty file with same file name.

        :param dst: destination directory. The directory can't exists before
        you execute this.

        **中文文档**

        创建一个目录的镜像拷贝, 与拷贝操作不同的是, 文件的副本只是在文件名上
        与原件一致, 但是是空文件, 完全没有内容, 文件大小为0。
        sdistination already exist!twbN(R6R;tostpathRt	ExceptionRtwalktreplacetmkdirtjointopen(
Rtdsttsrctfolder_to_createtfile_to_createtcurrent_foldert_t	file_listR#R;((spathlib_mate/mate_tool_box.pyt	mirror_to�s"
			"
cCs�ddl}|j�|dkrItjr4d}qItjrId}qInx1|jd�D] }|jd||jf�qYWdS(s�
        Execute every ``.py`` file as main script.

        :param py_exe: str, python command or python executable path.

        **中文文档**

        将目录下的所有Python文件作为主脚本用当前解释器运行。
        i����Ntpython2tpython3s.pys%s "%s"(	t
subprocessR6tNonetsixtPY2tPY3t
select_by_exttPopenR;(Rtpy_exeRbR((spathlib_mate/mate_tool_box.pytexecute_pyfile�s

			cCs
|jdkS(Ns.py(text(R((spathlib_mate/mate_tool_box.pyR3R4c	Cs�|j�x�|j|�D]�}y�t|jd��=}t�}x*|D]"}|j|jd�j��qHWWdQXt|jd��&}|jdj	|�j
d��WdQXWqtk
r�}|�qXqWdS(s�
        Trail white space at end of each line for every ``.py`` file.

        **中文文档**

        将目录下的所有被选择的文件中行末的空格删除。
        trbsutf-8NROs
(R6RRWR;RR(tdecodetrstriptwriteRVR	RR(RRJRtftlinestlinete((spathlib_mate/mate_tool_box.pyttrail_spaces
	
&)c	Ks�|j�x�|jd�D]y}t|jd��}|j�jd�}WdQXtj||�}t|jd��}|j|j	d��WdQXqWdS(s
        Auto convert your python code in a directory to pep8 styled code.

        :param kwargs: arguments for ``autopep8.fix_code`` method.

        **中文文档**

        将目录下的所有Python文件用pep8风格格式化。增加其可读性和规范性。
        s.pyRlsutf-8NRO(
R6RgRWR;treadRmtautopep8tfix_codeRoR	(RtkwargsRRptcodetformatted_code((spathlib_mate/mate_tool_box.pyRv#s

N(t__name__t
__module__RtpropertyRRRRR!R*R0R>R?RFRRMRNR_RcRjRtRv(((spathlib_mate/mate_tool_box.pyR
s	!0	"(RPRdRRvtmate_path_filtersRthelperRtmate_tool_box_zipRR(((spathlib_mate/mate_tool_box.pyt<module>s