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_zip.pyc
�
�´ac@s�dZddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZddl
mZejejZd	�Zd
efd��YZdS(s 
Provide zip related functions.
i����(tprint_functionN(tdatetime(tZipFilet
ZIP_STOREDtZIP_DEFLATEDi(tall_true(trepr_data_sizecCs/djgt|�D]}tjt�^q�S(Nt(tjointrangetrandomtchoicetalpha_digits(tlengtht_((s!pathlib_mate/mate_tool_box_zip.pytrand_strst
ToolBoxZipcBsPeZdZd�Zdeeeeed�Zdddddded�Z	RS(s(
    Provide zip related functions.
    cCsDdjtj�jd�td��}|j|}|jd|�S(Ns
-{}-{}.zips%Y-%m-%d-%Hh-%Mm-%Ssitnew_basename(tformatRtnowtstrftimeRtbasenametchange(tselftsurfixR((s!pathlib_mate/mate_tool_box_zip.pyt_auto_zip_archive_dsts

cCsk|j�|d
kr%|j�}n|jd|�}|jj�jd�s^td��n|j�r�|s�t	d|��q�n|r�t
}nt}|jj�s�|r�t
j|jj�q�n|r�d|}t|�nt
j�}	|j�r�d}
t�}x@|jd�D]/}||�r|j|�|
|j7}
qqW|r�djt|�t|
��}t|�nt|jd	|��J}
t
j|j�x0|D](}|j|�j�}|
j|�q�WWd
QXnP|j�r5t|jd	|��*}
t
j|jj�|
j|j�Wd
QXnt
j|	�|rgdj|j �}t|�nd
S(s_
        Make a zip archive.

        :param dst: output file path. if not given, will be automatically assigned.
        :param filters: custom path filter. By default it allows any file.
        :param compress: compress or not.
        :param overwrite: overwrite exists or not.
        :param verbose: display log or not.
        :return:
        tnew_abspaths.zips+zip archive name has to be endswith '.zip'!s'%s' already exists!sMaking zip archive for '%s' ...is**/*s/Got {} files, total size is {}, compressing ...twNsComplete! Archive size is {}.(!t
assert_existstNoneRRRtlowertendswitht
ValueErrortexiststIOErrorRRtparenttostmakedirstabspathtprinttgetcwdtis_dirtlisttglobtappendtsizeRtlenRRtchdirtrelative_tot__str__twritetis_filetsize_in_text(Rtdsttfilterstcompresst	overwriteR%tverbosetcompressiontmsgtcurrent_dirt
total_sizetselectedtptftrelpath((s!pathlib_mate/mate_tool_box_zip.pytmake_zip_archive%sV
	

	



csKd�}�j�|���x5�D]-}	|	jd�sJ|	jd�r&t�q&q&W|���x&�D]}
|
jd�sjt�qjqjW|����r�n]g�D]}	|	j�^q��g�D]}	|	j�^q��g�D]}	|	j�^q���������fd�}�jd|d|dtd	td
t�dS(s�
        Create a compressed zip archive backup for a directory.

        :param dst: the output file path.
        :param ignore: file or directory defined in this list will be ignored.
        :param ignore_ext: file with extensions defined in this list will be ignored.
        :param ignore_pattern: any file or directory that contains this pattern
            will be ignored.
        :param ignore_size_smaller_than: any file size smaller than this
            will be ignored.
        :param ignore_size_larger_than: any file size larger than this
            will be ignored.

        **中文文档**

        为一个目录创建一个备份压缩包。可以通过过滤器选择你要备份的文件。
        cSs:|dkrgSt|ttf�r/t|�S|gSdS(N(Rt
isinstancettupleR*(targ((s!pathlib_mate/mate_tool_box_zip.pytpreprocess_arg�s

t/s\t.cs�|j��j}�s'|j�}nx!�D]}|j|�r.tSq.W�r]|j}n|jj�}|�kr|tSx�D]}||kr�tSq�W�r�|j�kr�tSn�r�|j�kr�tSntS(N(R0R&Rt
startswithtFalsetextR-tTrue(R?RAtiRKtpattern(tcase_sensitivetignoret
ignore_exttignore_patterntignore_size_larger_thantignore_size_smaller_thanR(s!pathlib_mate/mate_tool_box_zip.pyR6�s*

R5R6R7R8R9N(tassert_is_dir_and_existsRIR RRBRLRJ(RR5RPRQRRRTRSRORFRMRKR6((RORPRQRRRSRTRs!pathlib_mate/mate_tool_box_zip.pytbackuprs&		




!$	N(
t__name__t
__module__t__doc__RRRRLRJRBRV(((s!pathlib_mate/mate_tool_box_zip.pyRs		H(RYt
__future__RR$R
tstringRtzipfileRRRtmate_path_filtersRthelperRt
ascii_letterstdigitsRRtobjectR(((s!pathlib_mate/mate_tool_box_zip.pyt<module>s