# eric7.Utilities.FtpUtilities

Module implementing some FTP related utilities.

### Global Attributes

None

### Classes

FtpDirLineParser | Class to parse lines returned by a FTP LIST command.
FtpDirLineParserError | Exception class raised, if a parser issue was detected.

### Functions

None

## FtpDirLineParser

Class to parse lines returned by a FTP LIST command.

### Derived from

QObject

### Class Attributes

MonthnamesNumbers

### Class Methods

None

### Methods

FtpDirLineParser | Constructor
__ignoreLine | Private method to check, if the line should be ignored.
__parseUnixLine | Private method to parse a Unix style directory listing line.
__parseUnixMode | Private method to parse a Unix mode string modifying the given URL info object.
__parseUnixTime | Private method to parse a Unix date and time indication modifying the given URL info object.
__parseWindowsLine | Private method to parse a Windows style directory listing line.
__parseWindowsTime | Private method to parse a Windows date and time indication modifying the given URL info object.
__splitUnixLine | Private method to split a line of a Unix like directory listing.
parseLine | Public method to parse a directory listing line.

### Static Methods

None

#### FtpDirLineParser (Constructor)

FtpDirLineParser(parent=None)

Constructor

parent
  reference to the parent object (QObject)

#### FtpDirLineParser.__ignoreLine

__ignoreLine(line)

Private method to check, if the line should be ignored.

line
  to check (string)

Return:
  flag indicating to ignore the line (boolean)

#### FtpDirLineParser.__parseUnixLine

__parseUnixLine(line)

Private method to parse a Unix style directory listing line.

line
  directory line to be parsed (string)

Return:
  URL info object containing the valid data (EricUrlInfo)

#### FtpDirLineParser.__parseUnixMode

__parseUnixMode(modeString, urlInfo)

Private method to parse a Unix mode string modifying the given URL info object.

modeString
  mode string to be parsed (string)
urlInfo
  reference to the URL info object (EricUrlInfo)

Raises FtpDirLineParserError:
  Raised if the mode cannot be parsed.

#### FtpDirLineParser.__parseUnixTime

__parseUnixTime(monthAbbreviation, day, yearOrTime, urlInfo)

Private method to parse a Unix date and time indication modifying the given URL info object.

Date time strings in Unix-style directory listings typically have one of these formats:

- "Nov 23 02:33" (month name, day of month, time)
- "May 26 2005" (month name, day of month, year)

monthAbbreviation
  abbreviation of the month name (string)
day
  day of the month (string)
yearOrTime
  string giving the year or a time (string)
urlInfo
  reference to the URL info object (EricUrlInfo)

Raises FtpDirLineParserError:
  Raised if the month abbreviation is not recognized.

#### FtpDirLineParser.__parseWindowsLine

__parseWindowsLine(line)

Private method to parse a Windows style directory listing line.

line
  directory line to be parsed (string)

Return:
  URL info object containing the valid data (EricUrlInfo)

Raises FtpDirLineParserError:
  Raised if the line is not of a recognized Windows format.

#### FtpDirLineParser.__parseWindowsTime

__parseWindowsTime(date, time, urlInfo)

Private method to parse a Windows date and time indication modifying the given URL info object.

Date time strings in Windows-style directory listings typically have the format "10-23-12 03:25PM" (month-day_of_month-two_digit_year, hour:minute, am/pm).

date
  date string (string)
time
  time string (string)
urlInfo
  reference to the URL info object (EricUrlInfo)

Raises FtpDirLineParserError:
  Raised if either of the strings is not recognized.

#### FtpDirLineParser.__splitUnixLine

__splitUnixLine(line)

Private method to split a line of a Unix like directory listing.

It splits the line into meta data, number of links, user, group, size, month, day, year or time and name.

line
  directory line to split (string)

Return:
  tuple of nine strings giving the meta data, number of links, user, group, size, month, day, year or time and name

Raises FtpDirLineParserError:
  Raised if the line is not of a recognized Unix format.

#### FtpDirLineParser.parseLine

parseLine(line)

Public method to parse a directory listing line.

This implementation support Unix and Windows style directory listings. It tries Unix style first and if that fails switches to Windows style. If that fails as well, an exception is raised.

line
  directory line to be parsed (string)

Return:
  URL info object containing the valid data (EricUrlInfo)

Up

## FtpDirLineParserError

Exception class raised, if a parser issue was detected.

### Derived from

Exception

### Class Attributes

None

### Class Methods

None

### Methods

None

### Static Methods

None

Up