Package twisted :: Package protocols :: Module ftp :: Class FTPFileListProtocol
[frames | no frames]

Class FTPFileListProtocol

BaseProtocol --+        
               |        
        Protocol --+    
                   |    
        LineReceiver --+
                       |
                      FTPFileListProtocol


Parser for standard FTP file listings

This is the evil required to match:
   -rw-r--r--   1 root     other        531 Jan 29 03:26 README

If you need different evil for a wacky FTP server, you can override this.

It populates the instance attribute self.files, which is a list containing dicts with the following keys (examples from the above line): Note that the 'date' value will be formatted differently depending on the date. Check http://cr.yp.to/ftp.html if you really want to try to parse it.
Method Summary
  __init__(self)
  lineReceived(self, line)
Override this for when each line is received.
    Inherited from LineReceiver
  clearLineBuffer(self)
Clear buffered data.
  dataReceived(self, data)
Protocol.dataReceived.
  lineLengthExceeded(self, line)
Called when the maximum line length has been reached.
  rawDataReceived(self, data)
Override this for when raw data is received.
  sendLine(self, line)
Sends a line to the other end of the connection.
  setLineMode(self, extra)
Sets the line-mode of this receiver.
  setRawMode(self)
Sets the raw mode of this receiver.
    Inherited from Protocol
  connectionFailed(self)
(Deprecated)
  connectionLost(self, reason)
Called when the connection is shut down.
    Inherited from BaseProtocol
  connectionMade(self)
Called when a connection is made.
  makeConnection(self, transport)
Make a connection to a transport and a server.

Instance Variable Summary
  files: list of dicts describing the files in this listing

Class Variable Summary
str delimiter: The line-ending delimiter to use.
SRE_Pattern fileLinePattern = ^(.)(.{9})\s+\d*\s*(\S+)\s+(\S+)\s+(\d...
    Inherited from LineReceiver
str _LineReceiver__buffer = ''
int line_mode = 1                                                                     
int MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped).
    Inherited from Protocol
tuple __implements__ = (<class twisted.internet.interfaces.IPr...
    Inherited from BaseProtocol
int connected = 0                                                                     
NoneType transport = None                                                                  

Method Details

lineReceived(self, line)

Override this for when each line is received.
Overrides:
twisted.protocols.basic.LineReceiver.lineReceived (inherited documentation)

Instance Variable Details

files

list of dicts describing the files in this listing

Class Variable Details

delimiter

The line-ending delimiter to use. By default this is '\r\n'.
Type:
str
Value:
'''
'''                                                                    

fileLinePattern

Type:
SRE_Pattern
Value:
^(.)(.{9})\s+\d*\s*(\S+)\s+(\S+)\s+(\d+)\s+(... .. ..:..)\s+(.*?)\r?$  

Generated by Epydoc 2.0 on Tue Dec 9 17:48:18 2003 http://epydoc.sf.net