
    !hR                         S SK r S SKJrJr  S SK Jr  S SKJr  SS\S\S\S	S4S
 jjr	SSS.S\S\\
   S\S\S\S\S\S\S	S4S jjrg)    N)FTP
error_perm)dirname)IOTftppath
first_callreturnc                      U R                  U5        g! [         aD    [        U [        U5      S5        U R	                  U5        U(       a  U R                  U5         g gf = f)zSet the current directory of the FTP connection given in the ``ftp``
argument (as a ftplib.FTP object), creating all parent directories if they
don't exist. The ftplib.FTP object must be already connected and logged in.
FN)cwdr   ftp_makedirs_cwdr   mkd)r   r   r	   s      W/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/scrapy/utils/ftp.pyr   r      sO    
 gdmU3GGDM s    A	A"!A"F)use_active_mode	overwritefilehostportusernamepasswordr   r   c                    [        5        nUR                  X#5        UR                  XE5        U(       a  UR                  S5        UR	                  S5        [
        R                  " U 5      u  p[        X5        U(       a  SOSnUR                  U SU
 3U5        UR                  5         SSS5        g! , (       d  f       g= f)zOpens a FTP connection with passed credentials,sets current directory
to the directory extracted from given path, then uploads the file to server
Fr   STORAPPE N)
r   connectloginset_pasvseek	posixpathsplitr   
storbinaryclose)r   r   r   r   r   r   r   r   r   r   filenamecommands               r   ftp_store_filer%      s     
#D		(%LL		!%OOD1&%&6'!H:.5

 
s   B!B55
C)T)r   ftplibr   r   r   typingr   strboolr   bytesintr%        r   <module>r.      s     "  # S d d , "
 U) 	
      
r-   