protocol.ftp.ls.listing Module

Listing parser.

wpull.protocol.ftp.ls.listing.FileEntry

A row in a listing.

wpull.protocol.ftp.ls.listing.name

str

Filename.

wpull.protocol.ftp.ls.listing.type

str, None

file, dir, symlink, other, None

wpull.protocol.ftp.ls.listing.size

int, None

Size of file.

wpull.protocol.ftp.ls.listing.date

datetime.datetime, None

A datetime object in UTC.

wpull.protocol.ftp.ls.listing.dest

str, None

Destination filename for symlinks.

wpull.protocol.ftp.ls.listing.perm

int, None

Unix permissions expressed as an integer.

alias of FileEntryType

class wpull.protocol.ftp.ls.listing.LineParser[source]

Bases: object

Parse individual lines in a listing.

guess_type(sample_lines)[source]

Guess the type of listing from a sample of lines.

parse(lines)[source]

Parse the lines.

parse_datetime(text)[source]

Parse datetime from line of text.

parse_msdos(lines)[source]

Parse lines from a MS-DOS format.

parse_nlst(lines)[source]

Parse lines from a NLST format.

parse_unix(lines)[source]

Parse listings from a Unix ls command format.

set_datetime_format(datetime_format)[source]

Set the datetime format.

exception wpull.protocol.ftp.ls.listing.ListingError[source]

Bases: ValueError

Error during parsing a listing.

class wpull.protocol.ftp.ls.listing.ListingParser(text=None, file=None)[source]

Bases: wpull.protocol.ftp.ls.listing.LineParser

Listing parser.

Parameters:
  • text (str) – A text listing.
  • file – A file object in text mode containing the listing.
parse_input()[source]

Parse the listings.

Returns:A iterable of ftp.ls.listing.FileEntry
Return type:iter
exception wpull.protocol.ftp.ls.listing.UnknownListingError[source]

Bases: wpull.protocol.ftp.ls.listing.ListingError

Failed to determine type of listing.

wpull.protocol.ftp.ls.listing.guess_listing_type(lines, threshold=100)[source]

Guess the style of directory listing.

Returns:unix, msdos, nlst, unknown.
Return type:str
wpull.protocol.ftp.ls.listing.parse_int(text)[source]

Parse a integer containing potential grouping characters.

wpull.protocol.ftp.ls.listing.parse_unix_perm(text)[source]

Parse a Unix permission string and return integer value.