-
<c       s    d  Z   % d k Z & d k Z ' d k Z * y5 + d k Z e Z [ , d k l Z e e _ [ Wn" - e j
 o . d k Z n X0 d d g Z 3 d Z	 7 d Z
 ; d e f d     YZ < d	 e f d
     YZ = d e f d     YZ > d e f d     YZ ? d e f d     YZ D e e i e e f Z H d Z L d f  d     YZ e a d   Z 4e a 6d   Z Jd   Z `d   Z wd   Z |d d d  Z d f  d     YZ  d   Z! (e" d j o )e!   n d S(   sV  An FTP client class and some helper functions.

Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds

Example:

>>> from ftplib import FTP
>>> ftp = FTP('ftp.python.org') # connect to host, default port
>>> ftp.login() # default, i.e.: user anonymous, passwd user@hostname
'230 Guest login ok, access restrictions apply.'
>>> ftp.retrlines('LIST') # list directory contents
total 9
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc
d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming
drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib
drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub
drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr
-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg
'226 Transfer complete.'
>>> ftp.quit()
'221 Goodbye.'
>>>

A nice test that reveals some of the network dialogue would be:
python ftplib.py -d localhost -l -p -l
N(   s   getfqdns   FTPs   Netrci   i   s   Errorc      s   ; t  Z ; RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/ftplib.pys   Error; s   	 s   error_replyc      s   < t  Z < RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/ftplib.pys   error_reply< s   	 s
   error_tempc      s   = t  Z = RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/ftplib.pys
   error_temp= s   	 s
   error_permc      s   > t  Z > RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/ftplib.pys
   error_perm> s   	 s   error_protoc      s   ? t  Z ? RS(   N(   s   __name__s
   __module__(    (    (    s   /usr/lib/python2.2/ftplib.pys   error_proto? s   	 s   
c      sQ  L t  Z d  Z \ ^ d Z _ d Z ` e Z a e Z b e Z	 c e Z
 d d Z j d d d d d  Z o d d d  Z  d   Z  d   Z  e Z  d   Z  d	   Z  d
   Z  d   Z  d   Z  d   Z  d   Z  d   Z  d   Z  d   Z  d   Z  d   Z d   Z d   Z *d   Z 1e d  Z  Xe d  Z! \d d d d  Z" vd e d  Z# e d  Z$ d d  Z% d   Z& d   Z' d    Z( d!   Z) d"   Z* d#   Z+ d$   Z, d%   Z- d&   Z. d'   Z/ 
d(   Z0 d)   Z1 d*   Z2 RS(+   sc  An FTP client class.

    To create a connection, call the class using these argument:
            host, user, passwd, acct
    These are all strings, and have default value ''.
    Then use self.connect() with optional host and port argument.

    To download a file, use ftp.retrlines('RETR ' + filename),
    or ftp.retrbinary() with slightly different arguments.
    To upload a file, use ftp.storlines() or ftp.storbinary(),
    which have an open file as argument (see their definitions
    below for details).
    The download/upload functions first issue appropriate TYPE
    and PORT or PASV commands.
i    s    i   c    sI   j k | o8 l |  i |  m | o m |  i | | |  n n d  S(   N(   s   hosts   selfs   connects   users   logins   passwds   acct(   s   selfs   hosts   users   passwds   acct(    (    s   /usr/lib/python2.2/ftplib.pys   __init__j s   

 c 
   s|  o r s | o s | |  _  n t | o t | |  _ n u d } v x t i |  i  |  i d t i  Dv ] } w | \ } } } } }	 x y2 y t i | | |  |  _ z |  i i |	  WnN { t i j
 o< } | |  i o } |  i i   n ~ t |  _  qh n X Pqh W |  i o  t i |  n  | |  _  |  i i d  |  _  |  i   |  _  |  i Sd S(   s   Connect to host.  Arguments are:
        - host: hostname to connect to (string, default previous host)
        - port: port to connect to (integer, default previous port)s!   getaddrinfo returns an empty listi    s   rbN(   s   hosts   selfs   ports   msgs   sockets   getaddrinfos   SOCK_STREAMs   ress   afs   socktypes   protos	   canonnames   sas   socks   connects   errors   closes   Nones   makefiles   files   getresps   welcome(
   s   selfs   hosts   ports   afs	   canonnames   protos   msgs   ress   socktypes   sa(    (    s   /usr/lib/python2.2/ftplib.pys   connecto s0   
 
 	% 	c    s=      |  i o  d G|  i |  i  GHn  |  i Sd S(   s`   Get the welcome message from the server.
        (this is read and squirreled away by connect())s	   *welcome*N(   s   selfs	   debuggings   sanitizes   welcome(   s   self(    (    s   /usr/lib/python2.2/ftplib.pys
   getwelcome s   c    s      | |  _ d S(   s   Set the debugging level.
        The required argument level means:
        0: no debugging output (default)
        1: print commands and responses but not body text etc.
        2: also print raw lines read and sent before stripping CR/LFN(   s   levels   selfs	   debugging(   s   selfs   level(    (    s   /usr/lib/python2.2/ftplib.pys   set_debuglevel s   c    s      | |  _ d S(   s   Use passive or active mode for data transfers.
        With a false argument, use the normal PORT mode,
        With a true argument, use the PASV command.N(   s   vals   selfs   passiveserver(   s   selfs   val(    (    s   /usr/lib/python2.2/ftplib.pys   set_pasv s   c    s     | d  d j p | d  d j oq  t |  }  x7  | d j o | | d d j o  | d } q= W | d  d | d | | } n  | Sd  S(   Ni   s   pass s   PASS i   s   
s   *(   s   ss   lens   i(   s   selfs   ss   i(    (    s   /usr/lib/python2.2/ftplib.pys   sanitize s   % %%c    sS     | t }  |  i d j o  d G|  i |  GHn  |  i i |  d  S(   Ni   s   *put*(   s   lines   CRLFs   selfs	   debuggings   sanitizes   socks   sendall(   s   selfs   line(    (    s   /usr/lib/python2.2/ftplib.pys   putline s    c    s=     |  i o  d G|  i |  GHn  |  i |  d  S(   Ns   *cmd*(   s   selfs	   debuggings   sanitizes   lines   putline(   s   selfs   line(    (    s   /usr/lib/python2.2/ftplib.pys   putcmd s    c    s     |  i i   }  |  i d j o  d G|  i |  GHn  | o  t  n  | d t j o  | d  } n&  | d t j o  | d  } n  | Sd  S(   Ni   s   *get*ii(   s   selfs   files   readlines   lines	   debuggings   sanitizes   EOFErrors   CRLF(   s   selfs   line(    (    s   /usr/lib/python2.2/ftplib.pys   getline s      c    s     |  i   }  | d d !d j ov  | d  }  x_  d oT  |  i   }  | d | }  | d  | j o | d d !d j o  Pn q< Wn  | Sd  S(   Ni   i   s   -i   s   
(   s   selfs   getlines   lines   codes   nextline(   s   selfs   nextlines   codes   line(    (    s   /usr/lib/python2.2/ftplib.pys   getmultiline s    
(c    s     |  i   }  |  i o  d G|  i |  GHn  | d  |  _  | d  }  | d j o  t |  n  | d j o  t |  n  | d j o  t	 |  n  | Sd  S(   Ns   *resp*i   i   s   4s   5s   123(
   s   selfs   getmultilines   resps	   debuggings   sanitizes   lastresps   cs
   error_temps
   error_perms   error_proto(   s   selfs   cs   resp(    (    s   /usr/lib/python2.2/ftplib.pys   getresp s    c    sD      |  i   }  | d d j o  t |  n  | Sd S(   s%   Expect a response beginning with '2'.i    s   2N(   s   selfs   getresps   resps   error_reply(   s   selfs   resp(    (    s   /usr/lib/python2.2/ftplib.pys   voidresp s
   c    s      d t  }  |  i d j o  d G|  i |  GHn  |  i i | t   |  i   }  | d  d d f j o  t
 |  n d S(   s   Abort a file transfer.  Uses out-of-band data.
        This does not follow the procedure from the RFC to send Telnet
        IP and Synch; that doesn't seem to work with the servers I've
        tried.  Instead, just send the ABOR command as OOB data.s   ABORi   s   *put urgent*i   s   426s   226N(   s   CRLFs   lines   selfs	   debuggings   sanitizes   socks   sendalls   MSG_OOBs   getmultilines   resps   error_proto(   s   selfs   lines   resp(    (    s   /usr/lib/python2.2/ftplib.pys   abort s    c    s'      |  i |   |  i   Sd S(   s'   Send a command and return the response.N(   s   selfs   putcmds   cmds   getresp(   s   selfs   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   sendcmd s   c    s'      |  i |   |  i   Sd S(   s8   Send a command and expect a response beginning with '2'.N(   s   selfs   putcmds   cmds   voidresp(   s   selfs   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   voidcmd s   c    sh      | i d  }  | d | d g }  | | }  d d i |  } |  i	 |  Sd S(   sU   Send a PORT command with the current host and the given
        port number.
        s   .i   s   PORT s   ,N(
   s   hosts   splits   hbytess   ports   pbytess   bytess   joins   cmds   selfs   voidcmd(   s   selfs   hosts   ports   hbytess   cmds   bytess   pbytes(    (    s   /usr/lib/python2.2/ftplib.pys   sendport s   c    s   d } |  i  t i j o d } n |  i  t i j o 	d } n 
| d j o t d  n d | | | d g } d t	 i
 | d  } |  i |  Sd S(	   sD   Send a EPRT command with the current host and the given port number.i    i   i   s   unsupported address familys    s   EPRT s   |N(   s   afs   selfs   sockets   AF_INETs   AF_INET6s   error_protos   hosts   ports   fieldss   strings
   joinfieldss   cmds   voidcmd(   s   selfs   hosts   ports   afs   fieldss   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   sendeprts   	c    s  d } t } x t i t d |  i t i d t i  D] } | \ } }	 } } }
 y, t i | |	 |  } | i |
  WnE t i j
 o3 } | o | i   n t } qC n XPqC W| o  t i |  n !| i d  "| i   d } #|  i i   d } $|  i t i j o %|  i | |  } n '|  i | |  } (| Sd S(   s3   Create a new socket and send a PORT command for it.s!   getaddrinfo returns an empty listi    i   N(   s   msgs   Nones   socks   sockets   getaddrinfos   selfs   afs   SOCK_STREAMs
   AI_PASSIVEs   ress   socktypes   protos	   canonnames   sas   binds   errors   closes   listens   getsocknames   ports   hosts   AF_INETs   sendports   resps   sendeprt(   s   selfs   afs   ress   protos   socks   resps   msgs   hosts	   canonnames   socktypes   sas   port(    (    s   /usr/lib/python2.2/ftplib.pys   makeports0   		+ 	
	c    sv   *+|  i t i j o" ,t |  i d   \ } } n+ .t |  i d  |  i	 i
    \ } } /| | f Sd  S(   Ns   PASVs   EPSV(   s   selfs   afs   sockets   AF_INETs   parse227s   sendcmds   hosts   ports   parse229s   socks   getpeername(   s   selfs   hosts   port(    (    s   /usr/lib/python2.2/ftplib.pys   makepasv*s   "*c    s  1?@t  } A|  i o B|  i   \ }	 } Ct i |	 | d t i	  d \ } }
 } } } Dt i | |
 |  } E| i |  F| t  j	 o G|  i d |  n H|  i |  } I| d d j o Jt |  n n L|  i   } M| t  j	 o N|  i d |  n O|  i |  } P| d d j o Qt |  n R| i   \ } } S| d  d j o Ut |  } n V| | f Sd S(   s  Initiate a transfer over the data connection.

        If the transfer is active, send a port command and the
        transfer command, and accept the connection.  If the server is
        passive, send a pasv command, connect to it, and start the
        transfer command.  Either way, return the socket for the
        connection and the expected size of the transfer.  The
        expected size may be None if it could not be determined.

        Optional `rest' argument can be a string that is sent as the
        argument to a RESTART command.  This is essentially a server
        marker used to tell the server to skip over any data up to the
        given marker.
        i    s   REST %ss   1i   s   150N(   s   Nones   sizes   selfs   passiveservers   makepasvs   hosts   ports   sockets   getaddrinfos   SOCK_STREAMs   afs   socktypes   protos   canons   sas   conns   connects   rests   sendcmds   cmds   resps   error_replys   makeports   socks   accepts   sockaddrs   parse150(   s   selfs   cmds   rests   sockaddrs   protos   socks   afs   canons   resps   hosts   socktypes   sas   ports   conns   size(    (    s   /usr/lib/python2.2/ftplib.pys   ntransfercmd1s,   	1c    s!   XYZ|  i | |  d Sd S(   s0   Like ntransfercmd() but returns only the socket.i    N(   s   selfs   ntransfercmds   cmds   rest(   s   selfs   cmds   rest(    (    s   /usr/lib/python2.2/ftplib.pys   transfercmdXs   c    s  \]^| o ^d } n _| o _d } n `| o `d } n a| d j o | d d f j o ct i   } dya et i i d  o ft i d } n4 gt i i d  o ht i d } n
 jd } Wn kt
 j
 o md } n Xn| | d | } n o|  i d |  } p| d d	 j o p|  i d
 |  } n q| d d	 j o q|  i d |  } n r| d d j o st |  n t| Sd S(   s   Login, default anonymous.s	   anonymouss    s   -s   LOGNAMEs   USERs   @s   USER i    s   3s   PASS s   ACCT s   2N(   s   users   passwds   accts   sockets   getfqdns   thishosts   oss   environs   has_keys   realusers   AttributeErrors   selfs   sendcmds   resps   error_reply(   s   selfs   users   passwds   accts   resps   thishosts   realuser(    (    s   /usr/lib/python2.2/ftplib.pys   login\s4      #  i    c    s   v|  i d  |  i | |  } xA d o6 | i |  } | o Pn | |  q1 W| i
   |  i   Sd S(   sU  Retrieve data in binary mode.

        `cmd' is a RETR command.  `callback' is a callback function is
        called for each block.  No more than `blocksize' number of
        bytes will be read from the socket.  Optional `rest' is passed
        to transfercmd().

        A new port is created for you.  Return the response code.
        s   TYPE Ii   N(   s   selfs   voidcmds   transfercmds   cmds   rests   conns   recvs	   blocksizes   datas   callbacks   closes   voidresp(   s   selfs   cmds   callbacks	   blocksizes   rests   datas   conn(    (    s   /usr/lib/python2.2/ftplib.pys
   retrbinaryvs   	 
c    s1  | o t } n |  i d  } |  i |  } | i d  } x d o | i
   } |  i d j o d G| GHn | o Pn | d t j o | d  } n& | d d j o | d  } n | |  qZ W| i   | i   |  i   Sd	 S(
   s  Retrieve data in line mode.
        The argument is a RETR or LIST command.
        The callback function (2nd argument) is called for each line,
        with trailing CRLF stripped.  This creates a new port for you.
        print_line() is the default callback.s   TYPE As   rbi   i   s   *retr*iis   
N(   s   callbacks
   print_lines   selfs   sendcmds   resps   transfercmds   cmds   conns   makefiles   fps   readlines   lines	   debuggings   CRLFs   closes   voidresp(   s   selfs   cmds   callbacks   fps   lines   resps   conn(    (    s   /usr/lib/python2.2/ftplib.pys	   retrliness*     
 c    s   |  i d  |  i |  } xD d o9 | i |  } | o Pn | i	 |  q. W| i
   |  i   Sd S(   s   Store a file in binary mode.s   TYPE Ii   N(   s   selfs   voidcmds   transfercmds   cmds   conns   fps   reads	   blocksizes   bufs   sendalls   closes   voidresp(   s   selfs   cmds   fps	   blocksizes   bufs   conn(    (    s   /usr/lib/python2.2/ftplib.pys
   storbinarys    
 c    s   |  i d  |  i |  } x d o | i   } | o Pn | d t j o6 | d t j o | d  } n | t } n | i	 |  q. W| i
   |  i   Sd S(   s   Store a file in line mode.s   TYPE Ai   iiN(   s   selfs   voidcmds   transfercmds   cmds   conns   fps   readlines   bufs   CRLFs   sendalls   closes   voidresp(   s   selfs   cmds   fps   bufs   conn(    (    s   /usr/lib/python2.2/ftplib.pys	   storliness    
  c    s'   d | } |  i |  Sd S(   s   Send new account name.s   ACCT N(   s   passwords   cmds   selfs   voidcmd(   s   selfs   passwords   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   accts   c    sa   d } x" | D] } | d | } q Wg  } |  i | | i  | Sd S(   sB   Return a list of files in a given directory (default the current).s   NLSTs    N(   s   cmds   argss   args   filess   selfs	   retrliness   append(   s   selfs   argss   cmds   filess   arg(    (    s   /usr/lib/python2.2/ftplib.pys   nlsts   	
 		c    s   d } t } | d o t | d  t d  j o! | d  | d f \ } } n x0 | D]% } | o | d | } n qn W|  i | |  d S(   s  List a directory in long form.
        By default list current directory to stdout.
        Optional last argument is callback function; all
        non-empty arguments before it are concatenated to the
        LIST command.  (This *should* only be used for a pathname.)s   LISTis    s    N(   s   cmds   Nones   funcs   argss   types   args   selfs	   retrlines(   s   selfs   argss   funcs   args   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   dirs   		+!
 	
c    sX   |  i d |  } | d d j o t |  n |  i d |  Sd S(   s   Rename a file.s   RNFR i    s   3s   RNTO N(   s   selfs   sendcmds   fromnames   resps   error_replys   voidcmds   toname(   s   selfs   fromnames   tonames   resp(    (    s   /usr/lib/python2.2/ftplib.pys   renames
   c    su   |  i d |  } | d  d d f j o | Sn1 | d  d j o t |  n t |  d S(   s   Delete a file.s   DELE i   s   250s   200i   s   5N(   s   selfs   sendcmds   filenames   resps
   error_perms   error_reply(   s   selfs   filenames   resp(    (    s   /usr/lib/python2.2/ftplib.pys   deletes   c    s   | d j o[ y |  i d  SWn= t j
 o. } | i d d  d j o
   n n Xn | d j o d } n d | } |  i |  Sd	 S(
   s   Change to a directory.s   ..s   CDUPi    i   s   500s    s   .s   CWD N(   s   dirnames   selfs   voidcmds
   error_perms   msgs   argss   cmd(   s   selfs   dirnames   msgs   cmd(    (    s   /usr/lib/python2.2/ftplib.pys   cwds   c    s   |  i d |  } | d  d j oW | d i   } y t |  SWn) t t f j
 o t	 |  Sn Xn d S(   s   Retrieve the size of a file.s   SIZE i   s   213N(
   s   selfs   sendcmds   filenames   resps   strips   ss   ints   OverflowErrors
   ValueErrors   long(   s   selfs   filenames   ss   resp(    (    s   /usr/lib/python2.2/ftplib.pys   sizes   c    s-   |  i d |  } t |  Sd S(   s+   Make a directory, return its full pathname.s   MKD N(   s   selfs   sendcmds   dirnames   resps   parse257(   s   selfs   dirnames   resp(    (    s   /usr/lib/python2.2/ftplib.pys   mkds   c    s   |  i d |  Sd S(   s   Remove a directory.s   RMD N(   s   selfs   voidcmds   dirname(   s   selfs   dirname(    (    s   /usr/lib/python2.2/ftplib.pys   rmds   c    s)   
|  i d  } t |  Sd S(   s!   Return current working directory.s   PWDN(   s   selfs   sendcmds   resps   parse257(   s   selfs   resp(    (    s   /usr/lib/python2.2/ftplib.pys   pwd
s   c    s0   |  i d  } |  i   | Sd S(   s   Quit, and close the connection.s   QUITN(   s   selfs   voidcmds   resps   close(   s   selfs   resp(    (    s   /usr/lib/python2.2/ftplib.pys   quits   c    sN   |  i o7 |  i i   |  i i   t |  _ |  _ n d S(   s8   Close the connection without assuming anything about it.N(   s   selfs   files   closes   socks   None(   s   self(    (    s   /usr/lib/python2.2/ftplib.pys   closes
   (3   s   __name__s
   __module__s   __doc__s	   debuggings   hosts   FTP_PORTs   ports   Nones   socks   files   welcomes   passiveservers   __init__s   connects
   getwelcomes   set_debuglevels   debugs   set_pasvs   sanitizes   putlines   putcmds   getlines   getmultilines   getresps   voidresps   aborts   sendcmds   voidcmds   sendports   sendeprts   makeports   makepasvs   ntransfercmds   transfercmds   logins
   retrbinarys	   retrliness
   storbinarys	   storliness   accts   nlsts   dirs   renames   deletes   cwds   sizes   mkds   rmds   pwds   quits   close(    (    (    s   /usr/lib/python2.2/ftplib.pys   FTPL s^   									
'	
c    s   #$|  d  d j o %t |   n &'t t j o( (d k } )| i d | i  a n *t i |   } +| o ,t Sn -| i	 d  } .y /t |  SWn) 0t t f j
 o 1t |  Sn Xd S(   s   Parse the '150' response for a RETR request.
    Returns the expected transfer size or None; size is not guaranteed to
    be present in the 150 message.
    i   s   150Ns   150 .* \((\d+) bytes\)i   (   s   resps   error_replys   _150_res   Nones   res   compiles
   IGNORECASEs   matchs   ms   groups   ss   ints   OverflowErrors
   ValueErrors   long(   s   resps   ms   res   s(    (    s   /usr/lib/python2.2/ftplib.pys   parse150s   c    s   69;|  d  d j o <t |   n =>t t j o" ?d k } @| i d  a n At i |   } B| o Ct |   n D| i	   } Ed i | d   } Ft | d  d >t | d  } G| | f Sd S(	   s   Parse the '227' response for a PASV request.
    Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
    Return ('host.addr.as.numbers', port#) tuple.i   s   227Ns#   (\d+),(\d+),(\d+),(\d+),(\d+),(\d+)s   .i   i   i   (   s   resps   error_replys   _227_res   Nones   res   compiles   searchs   ms   error_protos   groupss   numberss   joins   hosts   ints   port(   s   resps   res   ms   hosts   numberss   port(    (    s   /usr/lib/python2.2/ftplib.pys   parse2276s   %c    sM  JMO|  d  d j o Pt |   n Qt i |  d  } R| d j  o Rt |   n St i |  d | d  } T| d j  o Ut |   n V|  | d |  | d j o Wt |   n Xt i |  | d | !|  | d  } Yt	 |  d j o Zt |   n [| d } \t i | d  } ]| | f Sd S(	   s   Parse the '229' response for a EPSV request.
    Raises error_proto if it does not contain '(|||port|)'
    Return ('host.addr.as.numbers', port#) tuple.i   s   229s   (i    s   )i   i   N(   s   resps   error_replys   strings   finds   lefts   error_protos   rights   splits   partss   lens   peers   hosts   atois   port(   s   resps   peers   rights   hosts   partss   ports   left(    (    s   /usr/lib/python2.2/ftplib.pys   parse229Js"     (c    s  `ce|  d  d j o ft |   n g|  d d !d j o hd Sn id } jd } kt |   } lx l| | j  ou m|  | } n| d } o| d j o: p| | j p |  | d j o qPn r| d } n s| | } qs Wt| Sd S(	   s   Parse the '257' response for a MKD or PWD request.
    This is a response to a MKD or PWD request: a directory name.
    Returns the directoryname in the 257 reply.i   s   257i   s    "s    i   s   "N(   s   resps   error_replys   dirnames   is   lens   ns   c(   s   resps   cs   is   dirnames   n(    (    s   /usr/lib/python2.2/ftplib.pys   parse257`s$   		 !c    s   wxy|  GHd S(   s+   Default retrlines callback to print a line.N(   s   line(   s   line(    (    s   /usr/lib/python2.2/ftplib.pys
   print_linews   s    s   Ic 	   s  |}~| o ~| } n d | } |  i |  | i |  t |  i d   \ } } | i
 | |  | i d |  } | d  d d f j o t  n |  i d |  } | d  d d f j o t  n |  i   | i   d S(	   s+   Copy file from one FTP-instance to another.s   TYPE s   PASVs   STOR i   s   125s   150s   RETR N(   s
   targetnames
   sourcenames   types   sources   voidcmds   targets   parse227s   sendcmds
   sourcehosts
   sourceports   sendports   treplys   error_protos   sreplys   voidresp(	   s   sources
   sourcenames   targets
   targetnames   types   treplys   sreplys
   sourceports
   sourcehost(    (    s   /usr/lib/python2.2/ftplib.pys   ftpcp|s       c      sn   t  Z d  Z e Z e Z e Z e d  Z d   Z d   Z	 d   Z
 d   Z RS(   s   Class to parse & provide access to 'netrc' format files.

    See the netrc(4) man page for information on the file format.

    WARNING: This class is obsolete -- use module netrc instead.

    c    s  | oL t i i d  o& t i i t i d d  } n t d  n h  |  _ h  |  _	 t
 | d  } d } x3d o(| i   } | o Pn | o
 | i   o | i |  q n. | o# t |  |  i	 | <d } n | i   }	 t } } } }
 d } d } x| t |	  j  ow|	 | } | d t |	  j  o |	 | d } n
 t } | d j o d } n| d j o | o  | i    } | d } n | d	 j o | o | } | d } n | d
 j o | o | } | d } nl | d j o | o | }
 | d } n; | d j o | o# | } g  } d } Pn | d } qYW| oF | p |  i! |  _! | p |  i" |  _" |
 p |  i# |  _# n | o |  i i |  oM |  i | \ } } } | p | } | p | } |
 p | }
 n | | |
 f |  i | <n q W| i'   d  S(   Ns   HOMEs   .netrcs!   specify file to load or set $HOMEs   ri    i   s   defaults   machines   logins   passwords   accounts   macdef((   s   filenames   oss   environs   has_keys   paths   joins   IOErrors   selfs   _Netrc__hostss   _Netrc__macross   opens   fps   in_macros   readlines   lines   strips   macro_liness   appends   tuples
   macro_names   splits   wordss   Nones   hosts   users   passwds   accts   defaults   is   lens   w1s   w2s   lowers   _Netrc__defusers   _Netrc__defpasswds   _Netrc__defaccts   ousers   opasswds   oaccts   close(   s   selfs   filenames   fps   in_macros   w1s   passwds   hosts   macro_liness   users   wordss   accts
   macro_names   lines   opasswds   is   ousers   defaults   oaccts   w2(    (    s   /usr/lib/python2.2/ftplib.pys   __init__s|   	 
 

		 							

"c    s   |  i i   Sd S(   s4   Return a list of hosts mentioned in the .netrc file.N(   s   selfs   _Netrc__hostss   keys(   s   self(    (    s   /usr/lib/python2.2/ftplib.pys	   get_hostss   c    s   | i   } t } } } |  i i |  o |  i | \ } } } n | p |  i	 } | p |  i
 } | p |  i } | | | f Sd S(   s   Returns login information for the named host.

        The return value is a triple containing userid,
        password, and the accounting field.

        N(   s   hosts   lowers   Nones   users   passwds   accts   selfs   _Netrc__hostss   has_keys   _Netrc__defusers   _Netrc__defpasswds   _Netrc__defacct(   s   selfs   hosts   users   passwds   acct(    (    s   /usr/lib/python2.2/ftplib.pys   get_accounts   c    s   |  i i   Sd S(   s)   Return a list of all defined macro names.N(   s   selfs   _Netrc__macross   keys(   s   self(    (    s   /usr/lib/python2.2/ftplib.pys
   get_macross   c    s   |  i | Sd S(   s6   Return a sequence of lines which define a named macro.N(   s   selfs   _Netrc__macross   macro(   s   selfs   macro(    (    s   /usr/lib/python2.2/ftplib.pys	   get_macros   (   s   __name__s
   __module__s   __doc__s   Nones   _Netrc__defusers   _Netrc__defpasswds   _Netrc__defaccts   __init__s	   get_hostss   get_accounts
   get_macross	   get_macro(    (    (    s   /usr/lib/python2.2/ftplib.pys   Netrcs   			Ac     s  d }  t }
  x6  t i d d j o |  d }  t i d =q Wt i d d  d j o% t i d d }
 t i d =n t i d } t |  } 	| i |   
d } } }	 y t |
  } Wn= t j
 o. |
 t j	 o t i i d  n nP Xy | i |  \ } } }	 Wn) t j
 o t i i d  n X| i | | |	  x t i d D] } | d  d	 j o | i | d  n | d  d j oF d
 } | d o | d | d } n | i |  } nL  | d j o !| i | i  n$ #| i d | $t i i d  qW%| i   d S(   sU   Test program.
    Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...i    i   s   -di   s   -rs    s5   Could not open account file -- using anonymous login.s$   No account -- using anonymous login.s   -ls   CWDs    s   -ps   RETR i   N(   s	   debuggings   Nones   rcfiles   syss   argvs   hosts   FTPs   ftps   set_debuglevels   userids   passwds   accts   Netrcs   netrcs   IOErrors   stderrs   writes   get_accounts   KeyErrors   logins   files   dirs   cmds   sendcmds   resps   set_pasvs   passiveservers
   retrbinarys   stdouts   quit(   s	   debuggings   ftps   passwds   cmds   userids   netrcs   resps   hosts   files   accts   rcfile(    (    s   /usr/lib/python2.2/ftplib.pys   testsL   		  		 s   __main__(#   s   __doc__s   oss   syss   strings   SOCKSs   sockets   getfqdns   ImportErrors   __all__s   MSG_OOBs   FTP_PORTs	   Exceptions   Errors   error_replys
   error_temps
   error_perms   error_protos   errors   IOErrors   EOFErrors
   all_errorss   CRLFs   FTPs   Nones   _150_res   parse150s   _227_res   parse227s   parse229s   parse257s
   print_lines   ftpcps   Netrcs   tests   __name__(   s   parse227s   FTPs   FTP_PORTs   strings   parse257s
   all_errorss   parse229s   Netrcs   syss   tests   CRLFs   Errors
   print_lines   ftpcps   sockets   error_protos   __all__s   SOCKSs   MSG_OOBs   getfqdns   error_replys
   error_temps   parse150s   oss
   error_perm(    (    s   /usr/lib/python2.2/ftplib.pys   ? s@    			 		k.