#! /usr/bin/env python
"""Parse output of FTP LIST command.
Pure python implementation.
- Author: Oleg Broytman <phd@phd.pp.ru>.
- Copyright (C) 2003-2005 PhiloSoft Design.
- License: GPL.
+
See http://cr.yp.to/ftpparse.html, http://effbot.org/downloads#ftpparse,
http://c0re.23.nu/c0de/ftpparsemodule/ and http://www.ocgy.ubc.ca/~tang/treeftp
"""
-__version__ = "1.1.2"
-__author__ = "Oleg Broytman <phd@phd.pp.ru>"
-__copyright__ = "Copyright (C) 2003-2005 PhiloSoft Design"
-
-
-# ChangeLog:
-# 2005-04-26 version 1.1.2 [phd] Changed some comments and URLs.
-# 2003-07-23 version 1.1.1 [phd] Upgrade to Python 2.2: 0/1 => False/True.
-# 2003-07-17 version 1.1.0 [phd] Great renaming.
-# 2003-07-17 version 1.0.1 [phd] Preserve leading spaces in UNIX format.
-# 2003-02-17 version 1.0.0 [phd] First public version.
-# 2003-02-07 version 0.0.1 [phd] started the project.
-
-
+from __future__ import print_function
try:
from mx import DateTime
except ImportError:
def test():
#UNIX-style listing, without inum and without blocks
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 README")
- print ftpparse("dr-xr-xr-x 2 root other 512 Apr 8 1994 etc")
- print ftpparse("dr-xr-xr-x 2 root 512 Apr 8 1994 etc")
- print ftpparse("lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin")
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 README"))
+ print(ftpparse("dr-xr-xr-x 2 root other 512 Apr 8 1994 etc"))
+ print(ftpparse("dr-xr-xr-x 2 root 512 Apr 8 1994 etc"))
+ print(ftpparse("lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin"))
#FTP servers for Windoze:
- print ftpparse("---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z")
- print ftpparse("d--------- 1 owner group 0 May 9 19:45 Softlib")
+ print(ftpparse("---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z"))
+ print(ftpparse("d--------- 1 owner group 0 May 9 19:45 Softlib"))
#WFTPD for DOS:
- print ftpparse("-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp")
+ print(ftpparse("-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp"))
#NetWare:
- print ftpparse("d [R----F--] supervisor 512 Jan 16 18:53 login")
- print ftpparse("- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe")
+ print(ftpparse("d [R----F--] supervisor 512 Jan 16 18:53 login"))
+ print(ftpparse("- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe"))
#NetPresenz for the Mac:
- print ftpparse("-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit")
- print ftpparse("drwxrwxr-x folder 2 May 10 1996 network")
+ print(ftpparse("-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit"))
+ print(ftpparse("drwxrwxr-x folder 2 May 10 1996 network"))
#MultiNet (some spaces removed from examples)
- print ftpparse("00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)")
- print ftpparse("CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)")
+ print(ftpparse("00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)"))
+ print(ftpparse("CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)"))
#non-MutliNet VMS:
- print ftpparse("CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)")
+ print(ftpparse("CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)"))
#DOS format
- print ftpparse("04-27-00 09:09PM <DIR> licensed")
- print ftpparse("07-18-00 10:16AM <DIR> pub")
- print ftpparse("04-14-00 03:47PM 589 readme.htm")
+ print(ftpparse("04-27-00 09:09PM <DIR> licensed"))
+ print(ftpparse("07-18-00 10:16AM <DIR> pub"))
+ print(ftpparse("04-14-00 03:47PM 589 readme.htm"))
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 READ ME")
- print ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 DO NOT READ ME ")
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 READ ME"))
+ print(ftpparse("-rw-r--r-- 1 root other 531 Jan 29 03:26 DO NOT READ ME "))
if __name__ == "__main__":
test()