class_docstr: An FTP client class.
  
  To create a connection, call the class using these arguments:
          host, user, passwd, acct, timeout, source_address, encoding
  
  The first four arguments are all strings, and have default value ''.
  The parameter ´timeout´ must be numeric and defaults to None if not
  passed, meaning that no timeout will be set on any ftp socket(s).
  If a timeout is passed, then this is now the default timeout for all ftp
  socket operations for this instance.
  The last parameter is the encoding of filenames, which defaults to utf-8.
  
  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.
class_docstr_tok: ["An","FTP","client","class",".","To","create","a","connection",",","call","the","class","using","these","arguments",":","host",",","user",",","passwd",",","acct",",","timeout",",","source_address",",","encoding","The","first","four","arguments","are","all","strings",",","and","have","default","value","``",".","The","parameter","\u00b4timeout\u00b4","must","be","numeric","and","defaults","to","None","if","not","passed",",","meaning","that","no","timeout","will","be","set","on","any","ftp","socket","(","s",")",".","If","a","timeout","is","passed",",","then","this","is","now","the","default","timeout","for","all","ftp","socket","operations","for","this","instance",".","The","last","parameter","is","the","encoding","of","filenames",",","which","defaults","to","utf-8",".","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","."]
docstr: 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 REST command.  This is essentially a server
  marker used to tell the server to skip over any data up to the
  given marker.
code: def ntransfercmd(self, cmd, rest=None):
      """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 REST command.  This is essentially a server
      marker used to tell the server to skip over any data up to the
      given marker.
      """
      size = None
      if self.passiveserver:
          host, port = self.makepasv()
          conn = socket.create_connection(
              (host, port),
              self.timeout,
              source_address=self.source_address,
          )
          try:
              if rest is not None:
                  self.sendcmd("REST %s" % rest)
              resp = self.sendcmd(cmd)
              # Some servers apparently send a 200 reply to
              # a LIST or STOR command, before the 150 reply
              # (and way before the 226 reply). This seems to
              # be in violation of the protocol (which only allows
              # 1xx or error messages for LIST), so we just discard
              # this response.
              if resp[0] == "2":
                  resp = self.getresp()
              if resp[0] != "1":
                  raise error_reply(resp)
          except:
              conn.close()
              raise
      else:
          with self.makeport() as sock:
              if rest is not None:
                  self.sendcmd("REST %s" % rest)
              resp = self.sendcmd(cmd)
              # See above.
              if resp[0] == "2":
                  resp = self.getresp()
              if resp[0] != "1":
                  raise error_reply(resp)
              conn, sockaddr = sock.accept()
              if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
                  conn.settimeout(self.timeout)
      if resp[:3] == "150":
          # this is conditional in case we received a 125
          size = parse150(resp)
      return conn, size
  
imports: import sys
  import socket
  from socket import _GLOBAL_DEFAULT_TIMEOUT
label_desc: Use image node_id 22 for calling the FTP obj's underlying member method code with example usage: obj.ntransfercmd(cmd, rest) and returns: conn,  size