
    |h*                     (    d dl mZ d dlZd dlZddZy)    Nc                 6   t        j                  |       | j                  d      rt        j                  d}}n| j                  d      rt
        j                  d}}nx| j                  d      s| j                  d      rt
        j                  d}}nC| j                  d      s| j                  d	      rt
        j                  d
}}nt        d| z        d fd} || |      5 }|j                         ddd        |      S # 1 sw Y   xY w)a  Extract archive file.

    Parameters
    ----------
    path: str
        Path of archive file to be extracted.
    to: str, optional
        Directory to which the archive file will be extracted.
        If None, it will be set to the parent directory of the archive file.
    Nz.ziprz.tarz.tar.gzz.tgzzr:gzz.tar.bz2z.tbzzr:bz2z;Could not extract '%s' as no appropriate extractor is foundc                     t        | t        j                        r| j                         S | j                  D cg c]  }|j
                   c}S c c}w N)
isinstancezipfileZipFilenamelistmemberspath)fms     O/var/www/html/test/engine/venv/lib/python3.12/site-packages/gdown/extractall.pyr
   zextractall.<locals>.namelist"   s8    a)::< !		*1***s   Ac                 t    g } |       D ])  }t        j                  |      }|j                  |       + |S r   )ospjoinappend)r   filesfnamer
   tos      r   filelistzextractall.<locals>.filelist'   s>    a[ 	 EHHR'ELL	      )r   )	r   dirnameendswithr   r	   tarfileopen
ValueError
extractall)r   r   openermoder   r   r
   s    `    @r   r   r      s     
z[[}}V	v	||S	y	!T]]6%:||V	z	"dmmF&;||W!#'(
 	

+
 
d	 q	" A; s   ,DDr   )os.pathr   r   r   r   r    r   r   <module>r#      s      +r   